HTTP 07: Chunked Encoding

From Scratch · HTTP Server. Follows HTTP Server: Concurrency, and hands off to HTTP 08: Everything.
Before you start. This series builds a small copy of a web server: a program that listens on the network for a request - a short message asking for something - and sends back an answer. Your toy can already find where one request’s content, its body, begins and ends: an earlier stage taught it to read a labelled line at the top of the message, a header, called Content-Length - the sender writes down, in advance, exactly how many bytes (roughly one per typed character) of body are coming, so the toy reads that many and stops. The toy also now serves many visitors at once without one slow one freezing out the rest, which is what makes it worth keeping a connection open for a long time in the first place (HTTP Server: Concurrency). This lesson is about the one case Content-Length cannot cover: when the sender does not yet know how many bytes there will be.