Giter VIP home page Giter VIP logo

webserver's Introduction

Webserver

Almost-minimal implementation of HTTP server in Rust.

Started as a port-to-Rust from project for Computer Networks course. I develop it further just for the fun of it, so making it production-ready is an explicit non-goal. However, production-ready is often close to better, and making things better is often fun, so I expect this project to slowly mature.

Usage

The usage could be summarized in following line:

cargo run $content-directory -p $port

However, there are a few points definitely worth mentioning.

On startup, Webserver looks for subdirectories of content-directory and tries to treat each of them as separate host, binding its name and selected port for listening. This means that if you want to be able to access your page by http://localhost:{port}/index.html you need to have at least following structure:

$content-directory
└── localhost
    └── index.html

More real example would be

$content-directory
└── localhost
    ├── index.html
    ├── css
    │   └── styles.css
    └── other-page.html

where styles file can be accessed with http://localhost:{port}/css/styles.css.

Having something like

$content-directory
└── your-domain
    └── index.html

allows webserver to use http://your-domain:{port}/index.html. Under condition that your-domain points to something on 127.*.*.*, for example under /etc/hosts, of course.

It is impossible to host files under plain IP address, with no domain. You can access your files by IP, however.

This is, as You surely noticed, quite strange and not very useful. Webserver inherits that from his uni-project ancestor. This doesn't hurt me in any way, so I am not planning to change it.

Features

  • currently only GET and HEAD methods are supported
  • many hosts, each using its own thread
  • keeping connection alive for some time
  • separate thread pool for each host
  • graceful shutdown
  • per-host and global error pages ({status_code}.html)
  • some other, I'll update that list someday

To Do

  • tests
  • use flags for optional configuration
  • support more HTTP methods:
    • HEAD
    • PUT
    • POST
    • DELETE
  • support dynamic hosts
  • setup proper logging

webserver's People

Contributors

telpenarmo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.