h2_capsule (h2 v0.6.0)
View SourceRFC 9297 Capsule Protocol
Capsules are used to convey control information in HTTP CONNECT tunnels. Used by HTTP/2 WebTransport for stream multiplexing within a CONNECT stream.
Capsule format: +------------+------------+ | Type (i) | Length (i) | +------------+------------+ | Payload (*) | +-------------------------+
Type and Length are QUIC variable-length integers.
Summary
Functions
Create a DATAGRAM capsule.
Decode a single capsule from binary. Returns {ok, {Type, Payload}, Rest} | {more, N} | {error, Reason}
Decode all capsules from binary.
Convert capsule type integer to atom (if known).
Encode a capsule to binary.
Convert capsule type atom to integer.
Types
-type capsule() :: {Type :: capsule_type(), Payload :: binary()}.
-type capsule_type() :: non_neg_integer() | atom().
Functions
Create a DATAGRAM capsule.
-spec decode(binary()) -> {ok, capsule(), binary()} | {more, pos_integer()} | {error, term()}.
Decode a single capsule from binary. Returns {ok, {Type, Payload}, Rest} | {more, N} | {error, Reason}
Decode all capsules from binary.
-spec decode_type(non_neg_integer()) -> non_neg_integer() | atom().
Convert capsule type integer to atom (if known).
-spec encode(capsule_type(), binary()) -> binary().
Encode a capsule to binary.
-spec encode_type(atom()) -> non_neg_integer().
Convert capsule type atom to integer.