wt_h2_capsule (webtransport v0.2.6)
View SourceHTTP/2 WebTransport Capsules (draft-ietf-webtrans-http2-14)
All WebTransport data over HTTP/2 flows through capsules in the CONNECT stream body. This module handles encoding and decoding of WebTransport-specific capsule types.
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-14 §4.6: the Reason field MUST be at most 1024 UTF-8 bytes.
Construct a DATA_BLOCKED capsule indicating the connection-level limit reached.
Construct a DATAGRAM capsule wrapping the given payload.
Decode the first capsule from a binary, returning the capsule and remaining bytes.
Decode all capsules from binary.
Construct a DRAIN_SESSION capsule to signal graceful shutdown.
Encode a capsule record into its wire-format binary.
Construct a MAX_DATA capsule with the given connection-level limit.
Construct a MAX_STREAM_DATA capsule for the given stream and limit.
Construct a MAX_STREAMS capsule for bidirectional streams.
Construct a MAX_STREAMS capsule for unidirectional streams.
Construct a PADDING capsule of the given size or from raw bytes.
Construct a RESET_STREAM capsule for the given stream and error code.
Construct a STOP_SENDING capsule for the given stream and error code.
Construct a STREAM_DATA_BLOCKED capsule for the given stream and limit.
Construct a STREAMS_BLOCKED capsule for bidirectional streams.
Construct a STREAMS_BLOCKED capsule for unidirectional streams.
Get the human-readable name of a capsule type.
Construct a WT_STREAM capsule carrying data for the given stream.
Construct a WT_STREAM or WT_STREAM_FIN capsule depending on the fin flag.
Construct a WT_STREAM_FIN capsule carrying data with the fin bit set.
Construct a WT_STREAM_FIN or WT_STREAM capsule depending on the fin flag.
Types
-type capsule() :: {padding, binary()} | {wt_stream, stream_id(), binary()} | {wt_stream_fin, stream_id(), binary()} | {reset_stream, stream_id(), error_code()} | {stop_sending, stream_id(), error_code()} | {max_data, non_neg_integer()} | {max_stream_data, stream_id(), non_neg_integer()} | {max_streams_bidi, non_neg_integer()} | {max_streams_uni, non_neg_integer()} | {data_blocked, non_neg_integer()} | {stream_data_blocked, stream_id(), non_neg_integer()} | {streams_blocked_bidi, non_neg_integer()} | {streams_blocked_uni, non_neg_integer()} | {close_session, error_code(), binary()} | {drain_session} | {datagram, binary()} | {unknown, non_neg_integer(), binary()}.
-type error_code() :: non_neg_integer().
-type stream_id() :: non_neg_integer().
Functions
-spec close_session(error_code()) -> capsule().
Construct a CLOSE_SESSION capsule with the given error code and no reason.
-spec close_session(error_code(), binary()) -> capsule() | {error, reason_too_long}.
Construct a CLOSE_SESSION capsule with the given error code and reason. draft-14 §4.6: 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.
Construct a DATAGRAM capsule wrapping the given payload.
-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 binary.
-spec drain_session() -> capsule().
Construct a DRAIN_SESSION capsule to signal graceful shutdown.
Encode a capsule record into its wire-format binary.
-spec max_data(non_neg_integer()) -> capsule().
Construct a MAX_DATA capsule with the given connection-level limit.
-spec max_stream_data(stream_id(), non_neg_integer()) -> capsule().
Construct a MAX_STREAM_DATA capsule for the given stream and 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 padding(non_neg_integer() | binary()) -> capsule().
Construct a PADDING capsule of the given size or from raw bytes.
-spec reset_stream(stream_id(), error_code()) -> capsule().
Construct a RESET_STREAM capsule for the given stream and error code.
-spec stop_sending(stream_id(), error_code()) -> capsule().
Construct a STOP_SENDING capsule for the given stream and error code.
-spec stream_data_blocked(stream_id(), non_neg_integer()) -> capsule().
Construct a STREAM_DATA_BLOCKED capsule for the given stream and limit.
-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().
Get the human-readable name of a capsule type.
Construct a WT_STREAM capsule carrying data for the given stream.
Construct a WT_STREAM or WT_STREAM_FIN capsule depending on the fin flag.
Construct a WT_STREAM_FIN capsule carrying data with the fin bit set.
Construct a WT_STREAM_FIN or WT_STREAM capsule depending on the fin flag.