Achieve RFC 9110 Content-Length
Created November 6, 2026 · Updated November 6, 2026 · Achieve 3.1.0 · Qualified runtime: Node.js 24.22.2
Requirement levels: Content-Length includes status- and method-specific MUST NOT rules plus message-framing requirements.
Achieve derives static and media lengths from the selected opened representation. Node serializes dynamic responses and enforces the protocol-specific response framing used by HTTP/1.1 and HTTP/2.
Applicable requirements
- MUST NOT: HEAD carries Content-Length only when it equals the corresponding GET content size (RFC 9110 §8.6).
- MUST NOT: A 304 Content-Length, if sent, describes the corresponding 200; 1xx and 204 responses do not carry Content-Length.
- MUST NOT: A successful CONNECT response carries neither Content-Length nor Transfer-Encoding. Achieve does not implement successful CONNECT.
- For HTTP/1.1 requests, valid Content-Length determines body length; conflicting or invalid values require rejection and connection closure under RFC 9112 §6.3.
Static and media representations
Identity, gzip, and deflate static responses use the exact selected file size. Media 200 responses use the complete size; a 206 uses the selected range length and Content-Range. HEAD selects the same representation as GET and sends no body while retaining the corresponding full length.
Status-specific behavior
Achieve's 204 and 304 paths do not send content. The 205 completion boundary suppresses attempted content, removes Transfer-Encoding, and normalizes Content-Length to zero while preserving native response lifecycle behavior. Conditional failures and errors do not retain a stale static-resource length.
Servlet responses
For supported returned strings and byte buffers, Node can compute or serialize the resulting length. Applications that take response ownership can set Content-Length themselves and are responsible for matching their bytes; Achieve preserves native Node validation rather than silently correcting arbitrary application metadata.
Verification
Static-length and response-completion suites compare headers with exact bytes across identity and compressed representations, HEAD, 304, 412, 204, 205, errors, media ranges, and all four transports. HTTP/1.1 framing and malformed request-length probes verify parser behavior separately.
