nhttp_qpack_static_table (nhttp_lib v1.0.0)

View Source

QPACK static table for HTTP/3 (RFC 9204 Appendix A).

This module provides the 99-entry static table used by QPACK header compression. Forward lookup by index uses compile-time pattern matching for O(1) access. Reverse lookups by name or name+value use maps cached in persistent_term/0, built once at module load via the -on_load callback below. Concurrent first-use callers therefore never race to build the maps and never trigger more than the single global GC pair caused by the two persistent_term:put/2 calls.

Summary

Functions

Find the smallest index matching the given header name.

Find an index matching the given header name and value. Returns {ok, Index} for an exact name+value match, {name, Index} if only the name matches (smallest index), or error if the name is not found at all.

Look up a static table entry by index. Returns {ok, {Name, Value}} for valid indices 0-98, or {error, bad_index} for anything else.

Return the number of entries in the static table.

Types

index()

-type index() :: 0..98.

static_entry()

-type static_entry() :: {Name :: binary(), Value :: binary()}.

Functions

find_name(Name)

-spec find_name(binary()) -> {ok, index()} | error.

Find the smallest index matching the given header name.

Returns {ok, Index} if the name exists in the static table, or error if it does not. When multiple entries share the same name, the smallest index is returned.

find_name_value(Name, Value)

-spec find_name_value(binary(), binary()) -> {ok, index()} | {name, index()} | error.

Find an index matching the given header name and value. Returns {ok, Index} for an exact name+value match, {name, Index} if only the name matches (smallest index), or error if the name is not found at all.

lookup/1

-spec lookup(non_neg_integer()) -> {ok, static_entry()} | {error, bad_index}.

Look up a static table entry by index. Returns {ok, {Name, Value}} for valid indices 0-98, or {error, bad_index} for anything else.

size()

-spec size() -> 99.

Return the number of entries in the static table.