h1_capsule (h1 v0.2.1)

View Source

RFC 9297 Capsule Protocol codec over a byte stream.

Capsules convey control information inside any HTTP tunnel. Format:

+------------+------------+ | Type (i) | Length (i) | +------------+------------+ | Payload (*) | +-------------------------+

Type and Length are QUIC variable-length integers (RFC 9000 section 16).

This module is a pure codec: it owns no socket. Callers (including masque-over-H1) drive reads/writes themselves, feeding bytes in and retrieving capsules out. Identical wire format to h2_capsule and quic_h3_capsule so the three modules are interchangeable at the byte-stream level.

Summary

Types

capsule/0

-type capsule() :: {Type :: capsule_type(), Payload :: binary()}.

capsule_type/0

-type capsule_type() :: non_neg_integer() | atom().

Functions

datagram(Payload)

-spec datagram(binary()) -> capsule().

decode(Bin)

-spec decode(binary()) -> {ok, capsule(), binary()} | {more, pos_integer()} | {error, term()}.

decode_all(Bin)

-spec decode_all(binary()) -> {ok, [capsule()], binary()}.

decode_type(N)

-spec decode_type(non_neg_integer()) -> non_neg_integer() | atom().

encode(Type, Payload)

-spec encode(capsule_type(), binary()) -> binary().

encode_type(_)

-spec encode_type(atom()) -> non_neg_integer().