A from-scratch HTTP/1.1 server in Rust. No frameworks, no external HTTP libraries — just std and a couple of small crates.
Did this as part of the CodeCrafters HTTP Server challenge. Each commit is a new stage.
GET /echo/{str}— echoes back the stringGET /user-agent— returns the User-Agent headerGET /files/{filename}andPOST /files/{filename}— read/write files from a directory passed via--directory- gzip compression when the client sends
Accept-Encoding: gzip - Keep-alive connections — handles multiple requests on the same TCP connection
- Concurrent — each connection gets its own thread
cargo build --release
./target/release/codecrafters-http-server --directory /some/dirTry it:
curl http://localhost:4221/echo/hello
curl -H "Accept-Encoding: gzip" http://localhost:4221/echo/hello | gunzip
curl -X POST -d "hello" http://localhost:4221/files/test.txt
curl http://localhost:4221/files/test.txt