feat(http): HPACK, the header compression of HTTP/2 (step 1 of #72) #564
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/563-hpack"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #563
Task
Step 1 of #72: HPACK (RFC 7541), the header compression of HTTP/2, as a codec of its own in
std/http/src/hpack.trb. It is internal to the package (relative import likeparse.trb, not exported fromlib.trb) and changes noClientorServer.What and why
HpackDecoder.of(maxTableSize, maxListSize)withdecode,setMaxTableSizeandneverIndexed()(the never-indexed flag per field of the last block);HpackEncoder.of(maxTableSize)withencodeandsetMaxTableSize(pending size updates at the start of the next block: smallest first, then the last).authorization,proxy-authorization,cookie,set-cookieare never indexed; a string is Huffman-coded only where that is shorter. NETWORK.md section 12 / slice 12 and FIRST-PARTY.md gap 25 record it as built (gap 25 stays open).encodeanswersResult<Bytes, HpackError>instead of plainBytes, because an upper-case name has to be refused with anHpackError(not a compression error). Two consequences of the "Huffman only where shorter" rule: a three-octet string such as307stays plain where RFC C.6.2 codes it, and a full static match with an empty value (cookie: "") is the indexed field, not a never-indexed literal.Test
std/http/tests/hpack.test.trb(64 tests, VM and--nativein CI): Appendix C.1 to C.6 (decoded; C.4 and the first block of C.6 also byte for byte through the encoder), the 257 codes read back one by one plus the Kraft sum, each Huffman refusal as its own test, dynamic table cases, never-indexed, maxListSize, pending size updates, and 250 generated round trips through a table of 256. Run locally only with the VM of the nightly (torb check,format --check,doc --check --no-run,docs source --panics,docs skill --checkon std/http and docs: all clean); CI runs the gates and the native build.Approved. Checklist for
a24d9c2:std/http/tests/hpack.test.trb(64 tests: RFC Appendix C.1–C.6, every Huffman refusal, dynamic table, never-indexed, maxListSize, pending size updates, generated round trips). Combined status success for this head (gates, tier A, bootstrap linux-x64, pdisc, commit messages).lib.trb, with no change toClientorServer.authorization,proxy-authorization,cookieandset-cookieare never indexed. The decoder bounds allocations. No new dependencies or ports.The decision flagged in the PR body (
encodereturnsResult, Huffman only where shorter,cookie: ""is the indexed field) is sound on merit.Non-blocking:
HpackDecoder.fieldAtandliteralAtare notprivate; fine for an internal module.