hpack v2.0.0 HPack
Implementation of the HPack protocol, a compression format for efficiently representing HTTP header fields, to be used in HTTP/2.
Link to this section Summary
Functions
Decodes a header block fragment
as specified in RFC 7541.
Encodes a list of headers into a header block fragment
as specified in RFC 7541.
Link to this section Types
Link to this section Functions
Link to this function
decode(hbf, table, max_size \\ nil)
decode(header_block_fragment(), HPack.Table.t(), integer() | nil) :: {:ok, [header()]} | {:error, :decode_error}
Decodes a header block fragment
as specified in RFC 7541.
Returns the decoded headers as a List.
Examples
iex> {:ok, ctx} = HPack.Table.start_link(1000)
iex> HPack.decode(<< 0x82 >>, ctx)
{:ok, [{":method", "GET"}]}
Link to this function
encode(headers, table)
encode([header()], HPack.Table.t()) :: {:ok, header_block_fragment()} | {:error, :encode_error}
Encodes a list of headers into a header block fragment
as specified in RFC 7541.
Returns the header block fragment
.
Examples
iex> {:ok, ctx} = HPack.Table.start_link(1000)
iex> HPack.encode([{":method", "GET"}], ctx)
{:ok, << 0b10000010 >>}