Expand description
HPACK, the field compression of HTTP/2 (RFC 7541).
Decoder reads a complete field block (the payload of HEADERS plus its
CONTINUATION frames) against the static table and a dynamic table bounded
by the size this side advertised; Encoder writes one with a fixed,
simple strategy:
- a field found whole in the static or dynamic table is written as an index;
- a sensitive field (the caller’s flag, or a name
is_sensitivenames) is a literal never indexed, so no intermediary puts it into a compression context (RFC 7541 §7.1.3); - everything else is a literal with incremental indexing, its name indexed when a table holds it;
- a string is Huffman-coded when that is strictly shorter.
§The Appendix C vectors
tests/golden_vectors.rs decodes every block of RFC 7541 Appendix C and
re-encodes C.3, C.4, C.5.1, C.5.2 and C.6.1 byte for byte. Three blocks
are asserted decode-only, each for a stated reason of this strategy:
- C.5.3 and C.6.3 carry
set-cookie, which the RFC’s encoder indexes and this one writes never-indexed, because it is a credential. - C.6.2 Huffman-codes
307, whose Huffman form is exactly as long as its plain form; this encoder takes Huffman only when it is shorter.
The C.3 and C.5 vectors are written without Huffman coding, which is what
Encoder::set_huffman exists for; C.5 and C.6 start from a 256-octet
table on both sides, which Encoder::with_table_size states.
Structs§
- Decoder
- An HPACK decoder: one per connection direction.
- Encoder
- An HPACK encoder: one per connection direction.
Constants§
- DEFAULT_
TABLE_ SIZE - The default
SETTINGS_HEADER_TABLE_SIZE, and the largest dynamic table this crate’sEncoderuses: 4096 octets (RFC 9113 §6.5.2). - STATIC
- The static table, Appendix A: index 1 is the first entry.