h2_hpack (h2 v0.6.0)
View SourceHPACK Header Compression for HTTP/2 (RFC 7541)
This module provides HPACK encoding and decoding for HTTP/2 headers.
HPACK uses: - Static table: 61 predefined header name/value pairs - Dynamic table: Runtime-populated entries (FIFO eviction) - Huffman coding: Optional string compression - Integer encoding: Variable-length prefix encoding
Summary
Functions
Decode a HPACK-encoded header block.
Decode an integer with given prefix size.
Encode a list of headers.
Encode an integer with given prefix size.
Get the maximum dynamic table size.
Huffman decode a binary string.
Huffman encode a binary string.
Mark the decoder so that the next header block MUST start with a dynamic-table size update (RFC 7541 §4.2). Call this when the peer lowers SETTINGS_HEADER_TABLE_SIZE.
Create a new HPACK context with default settings.
Create a new HPACK context with specified max table size.
Set the maximum dynamic table size.
Record the peer-advertised SETTINGS_HEADER_TABLE_SIZE so the decoder can reject incoming size updates larger than this value (RFC 7541 §4.3). Also marks pending_size_update if reduced.
Types
-type context() :: #hpack_context{max_table_size :: non_neg_integer(), table_size :: non_neg_integer(), dynamic_table :: [{binary(), binary()}], dynamic_table_length :: non_neg_integer(), pending_size_update :: boolean(), peer_max_table_size :: non_neg_integer()}.
-type headers() :: [header()].
Functions
Decode a HPACK-encoded header block.
-spec decode_integer(binary(), 1..8) -> {ok, non_neg_integer(), binary()} | {error, term()}.
Decode an integer with given prefix size.
Encode a list of headers.
-spec encode_integer(non_neg_integer(), 1..8) -> binary().
Encode an integer with given prefix size.
-spec get_max_table_size(context()) -> non_neg_integer().
Get the maximum dynamic table size.
Huffman decode a binary string.
Huffman encode a binary string.
Mark the decoder so that the next header block MUST start with a dynamic-table size update (RFC 7541 §4.2). Call this when the peer lowers SETTINGS_HEADER_TABLE_SIZE.
-spec new_context() -> context().
Create a new HPACK context with default settings.
-spec new_context(non_neg_integer()) -> context().
Create a new HPACK context with specified max table size.
-spec set_max_table_size(non_neg_integer(), context()) -> context().
Set the maximum dynamic table size.
-spec set_peer_max_table_size(non_neg_integer(), context()) -> context().
Record the peer-advertised SETTINGS_HEADER_TABLE_SIZE so the decoder can reject incoming size updates larger than this value (RFC 7541 §4.3). Also marks pending_size_update if reduced.