This is a multi-threaded HTTP/1.1 server written in Rust.
I have written two accompagnying blog posts to this project:
- An introduction to networking theory to understand what HTTP and servers are about
- Architecture and implementation details of this particular server.
This server supporst the following path operations:
/user-agent: returns the client's User-Agent header./echo/<string>: echos the provided string back./sleep: waits for 10s and returns 'Good sleep!' (used to test concurrency).<path>or/files/<path>: support GET and POST requests to read or write files in the server's data directory./files/<path>: support both downloading (GET) and uploading (POST) files within the server's data directory./<path>: general path handler to support hosting a website.- If the path is empty (the root
/), it looks forindex.html. - If
index.htmlis missing, it automatically generates a directory listing (index) of the data folder.
- If the path is empty (the root
Note: security checks are performed to prevent path traversal attacks.
- Compile the Rust program into an executable:
cargo build --release- Run the executable:
./target/release/flyweight-http-serverThe compile_and_run.sh script automates the 2 steps above.
Simply run:
./compile_and_run.sh`to get the http-server going!