Lesson 3.2

Reading the body by content-length

How the header block tells you a body's exact size, why you slice exactly that many octets and no more, and the buffered body helpers the parser fills.

35 minsrc/parser.js, src/request.js
  • Compute a body's byte range as the half-open interval [bodyStart, bodyStart + content-length).
  • Explain why reading to the end of the buffer corrupts a pipelined request, and slice exactly content-length instead.
  • Add the READ_BODY phase to the parser and the buffered buffer()/text() helpers to Request.
Locked

This chapter is part of the framework capstone. Chapters 1 and 2 are free to build - unlock the rest to keep going.

Unlock the depth