nhttp_qpack_field_line (nhttp_lib v1.0.0)

View Source

QPACK field line representations (RFC 9204 Section 4.5).

Handles the field section prefix and five field line representation types used within encoded field sections on request and push streams.

The prefix carries the Required Insert Count and Base values needed to interpret dynamic table references. The five representation types encode header field lines as indexed references or literal values.

Representation types:

  • Indexed Field Line (Section 4.5.2)
  • Indexed Field Line with Post-Base Index (Section 4.5.3)
  • Literal Field Line with Name Reference (Section 4.5.4)
  • Literal Field Line with Post-Base Name Reference (Section 4.5.5)
  • Literal Field Line with Literal Name (Section 4.5.6)

Summary

Functions

Decode a field section prefix from binary data. MaxEntries is floor(MaxTableCapacity / 32). TotalInserts is the total number of inserts into the dynamic table so far.

Decode a single field line representation from binary data. Dispatches based on the leading bit pattern to determine which of the five representation types is encoded.

Encode a single field line representation. The Huffman flag controls whether string values (and literal names) are Huffman-coded.

Types

decode_error()

-type decode_error() :: incomplete | invalid_huffman | invalid_required_insert_count.

prefix()

-type prefix() :: #{required_insert_count := non_neg_integer(), base := non_neg_integer()}.

representation()

-type representation() ::
          {indexed, static | dynamic, non_neg_integer()} |
          {indexed_post_base, non_neg_integer()} |
          {literal_name_ref, static | dynamic, non_neg_integer(), binary(), boolean()} |
          {literal_post_base_name_ref, non_neg_integer(), binary(), boolean()} |
          {literal, binary(), binary(), boolean()}.

Functions

decode_prefix(Bin, MaxEntries, TotalInserts)

-spec decode_prefix(binary(), non_neg_integer(), non_neg_integer()) ->
                       {ok, prefix(), bitstring()} | {error, decode_error()}.

Decode a field section prefix from binary data. MaxEntries is floor(MaxTableCapacity / 32). TotalInserts is the total number of inserts into the dynamic table so far.

decode_representation/1

-spec decode_representation(binary()) -> {ok, representation(), bitstring()} | {error, decode_error()}.

Decode a single field line representation from binary data. Dispatches based on the leading bit pattern to determine which of the five representation types is encoded.

encode_prefix(RequiredInsertCount, Base, MaxEntries)

-spec encode_prefix(non_neg_integer(), non_neg_integer(), non_neg_integer()) -> iolist().

Encode a field section prefix.

The prefix consists of the Required Insert Count (with modular encoding per Section 4.5.1.1) and the sign bit plus Delta Base. MaxEntries is floor(MaxTableCapacity / 32).

encode_representation/2

-spec encode_representation(representation(), boolean()) -> iolist().

Encode a single field line representation. The Huffman flag controls whether string values (and literal names) are Huffman-coded.