Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🎉 Congratulations! 🎉

You have successfully built a working HTTP/1.1 server entirely from scratch!

You started with a raw TCP socket and progressively implemented the intricate details of the HTTP protocol. By the end, your server was capable of dynamic routing, concurrent connection handling, chunked transfer encoding, persistent connections, file serving, and even gzip compression!

Building foundational software like an HTTP server from scratch is one of the most effective ways to truly understand how the systems we rely on every day actually work under the hood.

What We Covered

Throughout this course, you tackled a massive slice of HTTP/1.1:

  • TCP Sockets: Binding, listening, and reading/writing raw bytes.
  • Protocol Parsing: Extracting the request line, parsing headers, and reading request bodies.
  • Routing & Methods: Handling GET and POST requests, and routing them to different endpoints.
  • Concurrency: Using threads or asynchronous tasks to handle multiple clients simultaneously without blocking.
  • Chunked Transfer Encoding: Implementing Transfer-Encoding: chunked to stream unknown-length payloads.
  • Persistent Connections: Implementing Keep-Alive to reuse TCP connections.
  • File Serving: Serving static files from disk with the correct MIME types.
  • Compression: Using GZIP via the Content-Encoding header to reduce bandwidth.

What We Didn’t Cover

HTTP is a massive, continuously evolving protocol. To keep this course focused, we intentionally omitted some advanced features:

  • Query Parameters: Parsing the ?key=value string from the URL path.
  • HTTPS / TLS: We only implemented plain-text HTTP. Adding TLS requires integrating cryptographic libraries and performing TLS handshakes over the TCP socket.
  • HTTP/2 and HTTP/3: These are fundamentally different protocols. HTTP/2 uses multiplexed binary framing over TCP, and HTTP/3 operates over UDP using QUIC.
  • Advanced Caching: ETags, Cache-Control, Last-Modified, and conditional requests (e.g., If-None-Match).
  • Cookies and Sessions: Setting Set-Cookie headers and managing server-side state.
  • WebSockets: The Upgrade header mechanism to turn an HTTP connection into a full-duplex WebSocket stream.

What’s Next?

If you enjoyed this, here are a few ideas for what you can do next:

  1. Explore HTTP/2: Read the RFCs for HTTP/2 to see how the protocol evolved to solve performance bottlenecks. It uses multiplexed binary framing over TCP, which is a completely different beast!
  2. Explore a Real Server: Look at the source code of a production-ready HTTP server in your language (like Hyper in Rust or net/http in Go). You’ll recognize many of the concepts you just built, and you can see how they handle edge cases and performance optimizations!
  3. Try another buildit course: If you enjoyed building an HTTP server from scratch, check out the other courses in the buildit project! Discover what other foundational technologies you can demystify by building them from the ground up.

Thanks for taking this journey with us. Now go out there and build something awesome!