Menu

1 / 6

http-from-scratch: one HTTP/1.1 server in Rust, built twice

DEV Community: rust·Abdeldjalil Chougui·8 days ago
#4iDx3S6K
#devtorust#devto#dev#request#chunked
Long article (1185 words) — no AI summary yet.
Reading 0:00
15s threshold

Most of us use HTTP every day through a framework. We write a handler, return a response, and the framework deals with the rest. That is the right way to ship software, and it also means many developers have never seen what "the rest" is: how a request is cut out of a stream of bytes, what keep-alive really asks of the server, why Content-Length and Transfer-Encoding together are a security problem.

http-from-scratch is my answer to that gap. It is an HTTP/1.1 server written from the socket up in Rust, twice: once on std::net::TcpListener with a hand-made thread pool, and once on Tokio. Both versions share the same I/O-free parser, handler and connection state machine, so the only difference between them is how bytes move. It is a learning project, not a production server, and this post is about what building it teaches.

What I built

An incremental parser. parser.rs never touches a socket. You feed it the bytes received so far.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.