Lesson 10.3

The chunked decoder - pumpBody and framing vs payload

Build pumpBody, the body state machine that streams a content-length or chunked body into the Request, strips every framing byte, and keeps consumed payload out of the accumulator.

38 minsrc/parser.js
  • Read the RFC 9112 chunked grammar byte by byte and separate framing from payload.
  • Decode content-length and chunked bodies in one pump that pushes only payload.
  • Reject malformed chunk framing as a 400 and reset the parser cleanly at end-of-body.
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