Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 03 · From Scratch · HTTP Server · with code: Go · about 24 min to read

Play it as a journeyTutor comes with a plan

HTTP 07: Chunked Encoding

Chunked Encoding
Chunked Encoding · Open board

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.

Lesson 20 of 117 in From Scratch

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 2013: a size too large to be true
  • The size you don’t have yet
  • A newsreader who doesn’t know the ending
  • Saying each piece’s size, not the whole story’s
  • The zero-size piece that ends the broadcast
  • The line nginx trusted too much
  • Writing one
  • Reading one
  • Trailers, and why almost nothing uses them
  • What chunked actually buys
  • Where this exact idea has kept going wrong
  • HTTP/2 and HTTP/3 deleted it
  • The one thing

Terms it explains: body, buffer, buffer overflow, chunked, chunk, hexadecimal, last chunk, and, The Server-Sent Events specification, RFC 9113 - HTTP/2, Go's own implementation.

Review From Scratch