nhttp_qpack_decoder (nhttp_lib v1.0.0)

View Source

QPACK decoder state machine (RFC 9204 Section 2.2).

Processes encoded field sections and encoder stream instructions. Maintains the dynamic table, handles blocked streams, and emits decoder instructions (section acknowledgments, insert count increments) back to the encoder.

The decoder receives:

When a field section references a dynamic table entry that has not yet been inserted, the stream is blocked until the encoder stream delivers the missing entries.

Summary

Functions

Decode an encoded field section from a request or push stream.

Feed encoder stream data into the decoder. Processes encoder instructions (table insertions, capacity changes, duplications) and unblocks any streams whose required insert count is now satisfied. Returns {ok, NewState, UnblockedResults} where UnblockedResults is a list of {StreamId, DecoderStreamData, FieldLines} tuples for streams that became unblocked.

Create a new QPACK decoder with the given configuration.

Types

config()

-type config() :: #{max_table_capacity => non_neg_integer(), max_blocked_streams => non_neg_integer()}.

field_line()

-type field_line() :: {binary(), binary()}.

state()

-opaque state()

unblocked_result()

-type unblocked_result() :: {nhttp_lib:stream_id(), iodata(), [field_line()]}.

Functions

decode_field_section(State, StreamId, Data)

-spec decode_field_section(state(), nhttp_lib:stream_id(), binary()) ->
                              {ok, state(), iodata(), [field_line()]} |
                              {blocked, state()} |
                              {error, term()}.

Decode an encoded field section from a request or push stream.

Returns {ok, NewState, DecoderStreamData, FieldLines} on success, {blocked, NewState} when the required insert count exceeds the current insert count, or {error, Reason} on failure.

feed_encoder_stream(State, Data)

-spec feed_encoder_stream(state(), binary()) -> {ok, state(), [unblocked_result()]} | {error, term()}.

Feed encoder stream data into the decoder. Processes encoder instructions (table insertions, capacity changes, duplications) and unblocks any streams whose required insert count is now satisfied. Returns {ok, NewState, UnblockedResults} where UnblockedResults is a list of {StreamId, DecoderStreamData, FieldLines} tuples for streams that became unblocked.

new(Config)

-spec new(config()) -> {ok, state()}.

Create a new QPACK decoder with the given configuration.