Skip to main content

Module hpack

Module hpack 

Source
Expand description

HPACK header compression for HTTP/2 (RFC 7541).

Implements the HPACK header compression algorithm used in HTTP/2 HEADERS frames. Includes:

  • Static table (61 entries per RFC 7541 Appendix A)
  • Dynamic table with eviction
  • Integer encoding/decoding with N-bit prefix
  • String literal encoding/decoding
  • Huffman encoding/decoding (RFC 7541 Appendix B)
  • HpackDecoder and HpackEncoder types

Structs§

HpackDecoder
HPACK decoder with dynamic table state.
HpackEncoder
HPACK encoder.

Constants§

HUFFMAN_TABLE
Full Huffman code table from RFC 7541 Appendix B. Index is the symbol value (0-255 for bytes, 256 for EOS). Each entry is (code: u32, nbits: u8).
STATIC_TABLE
Static HPACK table from RFC 7541 Appendix A. 61 entries, 1-indexed in the spec (index 0 here = spec index 1).

Functions§

decode_integer
Decode an HPACK integer with N-bit prefix.
decode_string
Decode a string literal from an HPACK-encoded buffer.
encode_integer
Encode an HPACK integer with N-bit prefix.
encode_string_huffman
Encode a string literal with Huffman coding if beneficial.
encode_string_literal
Encode a string literal without Huffman coding.
huffman_decode
Decode Huffman-encoded data (RFC 7541 Appendix B).
huffman_encode
Encode data using Huffman coding (RFC 7541 Appendix B).