Lesson 4.2

The Response writer - serialize once at send time

A Response object that collects a status, headers, and a body, then serializes them to framed wire bytes exactly once, with content-length measured in octets and a one-way headersSent flag.

40 minsrc/response.js
  • Explain why content-length can be computed correctly only at send time, and why it counts octets rather than characters.
  • Distinguish chainable configurators from terminal methods by their return type and their content-type behavior.
  • Build a Response whose single private _send is the one place framing happens, guarded by headersSent.
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