nhttp_huffman (nhttp_lib v1.1.1)
View SourceStatic Huffman encoder/decoder for HPACK (RFC 7541 Appendix B).
This module implements the static Huffman table used by HPACK for HTTP/2 header compression. The code table gives the shortest codes to the ASCII characters that are common in HTTP header values.
Summary
Functions
Decode a complete Huffman-encoded binary.
The input is a whole number of octets terminated by EOS padding (1-7
all-ones bits) to the byte boundary, as required by RFC 7541 Section
5.2. Returns {ok, Decoded}, or {error, invalid_huffman} if the
encoding is invalid (a non-all-ones or over-long pad, or an invalid
code).
Encode a binary using the HPACK Huffman table.
Types
Functions
-spec decode(Data :: binary()) -> {ok, Decoded :: binary()} | {error, decode_error()}.
Decode a complete Huffman-encoded binary.
The input is a whole number of octets terminated by EOS padding (1-7
all-ones bits) to the byte boundary, as required by RFC 7541 Section
5.2. Returns {ok, Decoded}, or {error, invalid_huffman} if the
encoding is invalid (a non-all-ones or over-long pad, or an invalid
code).
Encode a binary using the HPACK Huffman table.
The encoded binary is padded with EOS (all 1s) to the next byte boundary as required by RFC 7541 Section 5.2.