jhn_hpack (jhn_stdlib v5.10.2)
View SourceA HPACK library based on:
HPACK: Header Compression for HTTP/2 (rfc7541)
The headers are represented as a list of header, value binary tuples and and the dynamic index size update by the tuple {size_update, Integer}. The context is configurable with a max size and a hard limit in the size.
For the encoding context a without and never list of header names can be provided. The decoding context contains a list of the never index that can be selected from the context.
Summary
Functions
Decodes the binary into a list of headers and a context. Equivalent of decode(HPACK, #{}).
Decodes the binary into headers and a context used in futher decodings. First call is made with options, following calls with the context returned from the previous call to decode/2. Decode will give an exception if the binary is not well formed. Options are: limit => integer() -> the limit for the max size value, default 4096 max => integer() -> the max size for the dynamic table default 4096
Encodes the structured Erlang term as a binary and a context. Equivalent of encode(Fields, #{}).
Encodes the list of HPACK fields as an iolist or binary and a context used in futher encodings. First call is made with options, following calls with the context returned from the previous call to encode/2. Encode will give an exception if the erlang term is not well formed. Options are: return_type => binary | iolist -> default binary limit => integer() -> the limit for the max size value, default 4096 max => integer() -> the max size for the dynamic table default 4096 huffman_encode => boolean() -> if strings should be huffman encoded, default false without() => [header_name()] -> headers not to be indexed, default [] never() => [header_name()] -> headers never indexed, default []
Selects the header names that are marked as never in the decoding context.
Types
-type context() :: #context{table :: [header()], without :: [header_name()], never :: [header_name()], max :: non_neg_integer(), limit :: non_neg_integer(), length :: non_neg_integer(), size :: non_neg_integer(), huffman_encode :: boolean(), return_type :: binary | iolist}.
-type field() :: header() | size_update().
-type header() :: {header_name(), header_value()}.
-type header_name() :: binary().
-type header_value() :: binary().
-type opts() :: #{limit => non_neg_integer(), return_type => binary | iolist, huffman_encode => boolean()}.
-type size_update() :: {size_update, non_neg_integer()}.
Functions
Decodes the binary into a list of headers and a context. Equivalent of decode(HPACK, #{}).
Decodes the binary into headers and a context used in futher decodings. First call is made with options, following calls with the context returned from the previous call to decode/2. Decode will give an exception if the binary is not well formed. Options are: limit => integer() -> the limit for the max size value, default 4096 max => integer() -> the max size for the dynamic table default 4096
Encodes the structured Erlang term as a binary and a context. Equivalent of encode(Fields, #{}).
Encodes the list of HPACK fields as an iolist or binary and a context used in futher encodings. First call is made with options, following calls with the context returned from the previous call to encode/2. Encode will give an exception if the erlang term is not well formed. Options are: return_type => binary | iolist -> default binary limit => integer() -> the limit for the max size value, default 4096 max => integer() -> the max size for the dynamic table default 4096 huffman_encode => boolean() -> if strings should be huffman encoded, default false without() => [header_name()] -> headers not to be indexed, default [] never() => [header_name()] -> headers never indexed, default []
-spec never(context()) -> [header_name()].
Selects the header names that are marked as never in the decoding context.