quic_h3_connection (quic v1.3.1)
View SourceHTTP/3 connection management.
This module implements the HTTP/3 connection layer on top of QUIC. It manages critical unidirectional streams (control, QPACK encoder/decoder), request/response streams, and the HTTP/3 protocol state machine.
Summary
Functions
Cancel a push (client only). Sends CANCEL_PUSH to tell server we don't want this push.
Cancel a stream.
Close the connection.
Get peer settings.
Get the underlying QUIC connection pid.
Get local settings.
Initiate graceful shutdown.
Whether both sides negotiated RFC 9297 support.
Max payload we can fit in one H3 DATAGRAM for this stream, given the peer's max_datagram_frame_size minus the quarter-stream-id prefix. Returns 0 if RFC 9297 isn't live.
Open a client-initiated bidirectional stream outside the H3 request/response flow. When SignalType is a non-negative integer, the stream is pre-claimed so inbound data is delivered as stream_type_data owner messages. When undefined, behaves as a plain unclaimed stream.
Initiate a server push (server only). Sends a PUSH_PROMISE on the request stream and allocates a push ID. Returns the push ID for subsequent send_push_response/send_push_data calls.
Send a request (client only). Returns the stream ID for tracking the response.
Send body data on a stream.
Send an HTTP Datagram (RFC 9297) associated with a request stream.
Send data on a push stream (server only).
Send response headers on a push stream (server only).
Send a response (server only).
Send trailers on a stream.
Set the maximum push ID (client only). This enables server push up to the specified push ID.
Register a handler process to receive stream data. The handler will receive {quic_h3, Conn, {data, StreamId, Data, Fin}} messages. Any data buffered before registration is returned.
Register a handler with options. Options: - drain_buffer: If true (default), returns buffered data instead of sending as messages
Start an HTTP/3 connection as a client.
Start an HTTP/3 connection with options.
Unregister a stream handler. Future data will be sent to the connection owner.
Types
-type error_code() :: non_neg_integer().
-type role() :: client | server.
-type stream_id() :: non_neg_integer().
Functions
-spec cancel_push(pid(), non_neg_integer()) -> ok.
Cancel a push (client only). Sends CANCEL_PUSH to tell server we don't want this push.
Cancel a stream.
-spec cancel_stream(pid(), stream_id(), error_code()) -> ok.
-spec close(pid()) -> ok.
Close the connection.
Get peer settings.
Get the underlying QUIC connection pid.
Get local settings.
-spec goaway(pid()) -> ok.
Initiate graceful shutdown.
Whether both sides negotiated RFC 9297 support.
-spec max_datagram_size(pid(), stream_id()) -> non_neg_integer().
Max payload we can fit in one H3 DATAGRAM for this stream, given the peer's max_datagram_frame_size minus the quarter-stream-id prefix. Returns 0 if RFC 9297 isn't live.
-spec open_bidi_stream(pid(), non_neg_integer() | undefined) -> {ok, stream_id()} | {error, term()}.
Open a client-initiated bidirectional stream outside the H3 request/response flow. When SignalType is a non-negative integer, the stream is pre-claimed so inbound data is delivered as stream_type_data owner messages. When undefined, behaves as a plain unclaimed stream.
-spec push(pid(), stream_id(), [{binary(), binary()}]) -> {ok, non_neg_integer()} | {error, term()}.
Initiate a server push (server only). Sends a PUSH_PROMISE on the request stream and allocates a push ID. Returns the push ID for subsequent send_push_response/send_push_data calls.
Send a request (client only). Returns the stream ID for tracking the response.
Send body data on a stream.
Send an HTTP Datagram (RFC 9297) associated with a request stream.
-spec send_push_data(pid(), non_neg_integer(), binary(), boolean()) -> ok | {error, term()}.
Send data on a push stream (server only).
-spec send_push_response(pid(), non_neg_integer(), pos_integer(), [{binary(), binary()}]) -> ok | {error, term()}.
Send response headers on a push stream (server only).
-spec send_response(pid(), stream_id(), pos_integer(), [{binary(), binary()}]) -> ok | {error, term()}.
Send a response (server only).
Send trailers on a stream.
-spec set_max_push_id(pid(), non_neg_integer()) -> ok | {error, term()}.
Set the maximum push ID (client only). This enables server push up to the specified push ID.
-spec set_stream_handler(pid(), stream_id(), pid()) -> ok | {ok, [{binary(), boolean()}]} | {error, term()}.
Register a handler process to receive stream data. The handler will receive {quic_h3, Conn, {data, StreamId, Data, Fin}} messages. Any data buffered before registration is returned.
See also: set_stream_handler/4.
-spec set_stream_handler(pid(), stream_id(), pid(), map()) -> ok | {ok, [{binary(), boolean()}]} | {error, term()}.
Register a handler with options. Options: - drain_buffer: If true (default), returns buffered data instead of sending as messages
-spec start_link(pid(), binary(), pos_integer()) -> {ok, pid()} | {error, term()}.
Start an HTTP/3 connection as a client.
Start an HTTP/3 connection with options.
Unregister a stream handler. Future data will be sent to the connection owner.