wt_h3_capsule (webtransport v0.3.1)
View SourceHTTP/3 WebTransport capsules and stream/datagram headers.
HTTP/3 WebTransport uses: - capsules on the CONNECT stream for session control and flow control - native QUIC stream headers for data streams - HTTP Datagram framing for unreliable datagrams
Summary
Functions
Construct a CLOSE_SESSION capsule with the given error code and no reason.
Construct a CLOSE_SESSION capsule with the given error code and reason. draft-15 §5: the Reason field MUST be at most 1024 UTF-8 bytes.
Construct a DATA_BLOCKED capsule indicating the connection-level limit reached.
Decode the first capsule from a binary, returning the capsule and remaining bytes.
Decode all capsules from a binary, returning the list and any trailing bytes.
Decode an HTTP Datagram, returning the session ID and payload.
Decode a WebTransport stream header, returning the session ID and stream kind.
Construct a DRAIN_SESSION capsule to signal graceful shutdown.
Encode a capsule record into its wire-format binary.
Encode a bidirectional WebTransport stream header for the given session.
Encode an HTTP Datagram payload with the quarter stream ID prefix.
Encode a unidirectional WebTransport stream header for the given session.
Construct a MAX_DATA capsule with the given connection-level limit.
Construct a MAX_STREAMS capsule for bidirectional streams.
Construct a MAX_STREAMS capsule for unidirectional streams.
Convert a session ID to its quarter stream ID for datagram framing.
Convert a quarter stream ID back to the original session ID.
Construct a STREAMS_BLOCKED capsule for bidirectional streams.
Construct a STREAMS_BLOCKED capsule for unidirectional streams.
Return the human-readable atom for a capsule type code.
Types
-type capsule() :: {max_data, non_neg_integer()} | {data_blocked, non_neg_integer()} | {max_streams_bidi, non_neg_integer()} | {max_streams_uni, non_neg_integer()} | {streams_blocked_bidi, non_neg_integer()} | {streams_blocked_uni, non_neg_integer()} | {close_session, non_neg_integer(), binary()} | {drain_session} | {unknown, non_neg_integer(), binary()}.
-type stream_kind() :: bidi | uni.
Functions
-spec close_session(non_neg_integer()) -> capsule().
Construct a CLOSE_SESSION capsule with the given error code and no reason.
-spec close_session(non_neg_integer(), binary()) -> capsule() | {error, reason_too_long}.
Construct a CLOSE_SESSION capsule with the given error code and reason. draft-15 §5: the Reason field MUST be at most 1024 UTF-8 bytes.
-spec data_blocked(non_neg_integer()) -> capsule().
Construct a DATA_BLOCKED capsule indicating the connection-level limit reached.
-spec decode(binary()) -> {ok, capsule(), binary()} | {more, pos_integer()} | {error, term()}.
Decode the first capsule from a binary, returning the capsule and remaining bytes.
Decode all capsules from a binary, returning the list and any trailing bytes.
-spec decode_datagram(binary()) -> {ok, non_neg_integer(), binary()} | {more, pos_integer()} | {error, term()}.
Decode an HTTP Datagram, returning the session ID and payload.
-spec decode_stream_header(binary()) -> {ok, non_neg_integer(), stream_kind(), binary()} | {more, pos_integer()} | {error, term()}.
Decode a WebTransport stream header, returning the session ID and stream kind.
-spec drain_session() -> capsule().
Construct a DRAIN_SESSION capsule to signal graceful shutdown.
Encode a capsule record into its wire-format binary.
-spec encode_bidi_stream_header(non_neg_integer()) -> binary().
Encode a bidirectional WebTransport stream header for the given session.
-spec encode_datagram(non_neg_integer(), binary()) -> binary().
Encode an HTTP Datagram payload with the quarter stream ID prefix.
-spec encode_uni_stream_header(non_neg_integer()) -> binary().
Encode a unidirectional WebTransport stream header for the given session.
-spec max_data(non_neg_integer()) -> capsule().
Construct a MAX_DATA capsule with the given connection-level limit.
-spec max_streams_bidi(non_neg_integer()) -> capsule().
Construct a MAX_STREAMS capsule for bidirectional streams.
-spec max_streams_uni(non_neg_integer()) -> capsule().
Construct a MAX_STREAMS capsule for unidirectional streams.
-spec quarter_stream_id(non_neg_integer()) -> non_neg_integer().
Convert a session ID to its quarter stream ID for datagram framing.
-spec session_id_from_quarter_stream_id(non_neg_integer()) -> non_neg_integer().
Convert a quarter stream ID back to the original session ID.
-spec streams_blocked_bidi(non_neg_integer()) -> capsule().
Construct a STREAMS_BLOCKED capsule for bidirectional streams.
-spec streams_blocked_uni(non_neg_integer()) -> capsule().
Construct a STREAMS_BLOCKED capsule for unidirectional streams.
-spec type_name(non_neg_integer()) -> atom() | non_neg_integer().
Return the human-readable atom for a capsule type code.