HTTP Servers, Clients & Proxies
7 topics in this chapter
HTTP/1.1 Wire Format
Read HTTP/1.1 as bytes: start lines, headers, body framing, chunked transfer coding, connection rules, and interim responses.
http.Server Lifecycle
Trace one inbound HTTP request through http.Server, accepted sockets, IncomingMessage, ServerResponse, header commits, early bodies, parser errors, timeouts, and connection reuse.
HTTP Parsing with llhttp
How Node.js turns HTTP/1.1 bytes into IncomingMessage objects through llhttp state, parser callbacks, header limits, body delivery, errors, trailers, and upgrade handoff.
Routing and Middleware
Build a small framework-free HTTP handler with method and path routing, middleware composition, bounded JSON body parsing, and deliberate error responses.
Keep-Alive, Agents, and Pools
How Node.js reuses HTTP/1.1 TCP connections through keep-alive, http.Agent pools, server idle timers, stale pooled sockets, and reuse limits.
fetch and Undici
How outbound HTTP works in Node.js, from http.request() and ClientRequest through fetch, Undici dispatchers, pools, redirects, decoding, and pipelining.
Proxies, Static Files, and Streaming
Build the HTTP boundary where Node forwards requests, streams bodies, filters connection metadata, and serves file-backed responses.