QuicHttp3.Session (elixir_quic_http3 v1.0.0)

Copy Markdown View Source

Caller-driven HTTP/3 session with resumable QUIC admission.

Mutating failures return the advanced session. Call resume/1 to reconcile an unknown operation, or retry a definitely blocked operation after credit changes. Unknown operations are never replayed, including after result-cache eviction. A detected HTTP/3 connection error {:http3_error, :connection, code, reason} first closes the QUIC connection with that application error code (best effort under the operation deadline) and is then returned. Definitely credit-blocked stream writes are split into smaller ordered fragments under the original deadline; max_frame remains an upper bound. Native query calls and DNS retain their transport timeout bounds; the session deadline is an admission/reconciliation budget, not a shorter wall-clock bound.

QPACK: :qpack_max_table_capacity (default 4096) and :qpack_blocked_streams (default 16) are advertised in SETTINGS. A nonzero capacity opens local QPACK encoder and decoder streams, applies peer encoder instructions to a bounded dynamic table, holds blocked sections without reading further from their streams, and sends Section Acknowledgment, Stream Cancellation and Insert Count Increment through ordinary stream-write admission. 0/0 keeps the static/literal profile without QPACK streams. The local encoder is always static/literal.

WebTransport: webtransport: true (or router limits as a keyword list) advertises the draft-17 client SETTINGS and admits exactly one webtransport-h3 extended CONNECT after the peer's draft-17 SETTINGS and the connection's negotiated reliable reset and QUIC DATAGRAM support are confirmed. Peer WT streams and datagrams are associated through QuicHttp3.WebTransportRouter; deliveries are {:wt, connect_ref, event} poll events whose credit is released by webtransport_acknowledge/2. Closing the session, or the CONNECT stream ending, resets and stops every associated stream with WT_SESSION_GONE.

Early data (beta): before the handshake completes, request/4 with early_data: remembered_settings admits a GET, HEAD or OPTIONS request without a body as replayable QUIC 0-RTT stream operations, provided the connection offered 0-RTT. remembered_settings are the peer SETTINGS the caller remembered for the resumption partition; the request must fit their SETTINGS_MAX_FIELD_SECTION_SIZE. Control and QPACK streams are opened only after the handshake. When open/1 finds 0-RTT rejected, every early request is re-sent once on a fresh stream under the same request reference. When 0-RTT was accepted, a peer SETTINGS frame that omits or reduces a remembered non-default value this client understands is an H3_SETTINGS_ERROR connection error (RFC 9114 Section 7.2.4.2). At most eight requests are admitted early per connection.

Summary

Functions

Terminate transport resources without replaying pending application work.

Whether ref was carried in QUIC 0-RTT data that the server accepted.

Whether the connection currently offers QUIC 0-RTT for early requests.

Opens an explicitly negotiated extended CONNECT without closing its sending direction.

Admits explicit client migration to the concrete local {ip, port} (beta).

Whether the established connection resumed a TLS session.

Sends ordered request trailing HEADERS with FIN through resumable admission.

Releases delivery credit retained for a WT event receipt.

Sends CLOSE_WEBTRANSPORT_SESSION and FIN on the CONNECT stream.

Sends one HTTP DATAGRAM associated with the accepted WT session.

Returns the accepted WT session identity and maximum DATAGRAM payload.

Opens a session-associated WT stream; returns its QUIC stream ID as key.

Resets the send side with RESET_STREAM_AT, reliably delivering the WT prefix.

Writes raw WT stream bytes; FIN closes the send side.

Aborts the receive side with STOP_SENDING carrying a mapped application code.

Types

failure()

@type failure() ::
  {:error, t(), term()} | {:blocked, t(), term()} | {:unknown, t(), reference()}

t()

@type t() :: %QuicHttp3.Session{
  aborted_operation: term(),
  cleanup: term(),
  connection: term(),
  continuations: term(),
  control: term(),
  control_stream: term(),
  deadline: term(),
  early: term(),
  max_encoded_headers: term(),
  max_fields: term(),
  max_frame: term(),
  max_header_bytes: term(),
  max_retained_bytes: term(),
  next_request: term(),
  next_stream_id: term(),
  open?: term(),
  peer_streams: term(),
  pending: term(),
  qpack: term(),
  qpack_blocked: term(),
  qpack_blocked_streams: term(),
  qpack_decoder_stream: term(),
  qpack_encoder_stream: term(),
  qpack_known: term(),
  qpack_max_table_capacity: term(),
  qpack_out: term(),
  qpack_streams: term(),
  requests: term(),
  retired: term(),
  runnable: term(),
  timeout: term(),
  transport: term(),
  work: term(),
  wt: term()
}

Functions

abort(session)

Terminate transport resources without replaying pending application work.

This does not prove an indeterminate request was unsent. The returned session retains its abandoned operation identity in aborted_operation.

cancel(session, ref)

close(session)

connect(session, remote, port, opts)

early_data?(session, ref)

Whether ref was carried in QUIC 0-RTT data that the server accepted.

early_offered?(session)

Whether the connection currently offers QUIC 0-RTT for early requests.

extended_connect(session, protocol, fields, opts \\ [])

Opens an explicitly negotiated extended CONNECT without closing its sending direction.

migrate(session, local, opts)

Admits explicit client migration to the concrete local {ip, port} (beta).

Returns {:ok, session, ref} once the transport admitted migration; the outcome later arrives from poll/3 as {:migration, ref, {:ok, actual_local} | {:error, reason}}. The migration deadline is the operation deadline. A transport without migration returns :migration_unsupported.

new(opts \\ [])

open(session)

poll(session, max, opts \\ [])

ready(session)

request(session, fields, body, opts)

reset_send(session, ref)

resume(session)

resume(session, continuation)

resumed?(session)

Whether the established connection resumed a TLS session.

send_data(session, ref, bytes, fin, opts)

send_trailers(session, ref, fields, opts)

Sends ordered request trailing HEADERS with FIN through resumable admission.

suspend_blocked(session)

webtransport_acknowledge(session, receipt)

Releases delivery credit retained for a WT event receipt.

webtransport_close(session, code, reason, opts \\ [])

Sends CLOSE_WEBTRANSPORT_SESSION and FIN on the CONNECT stream.

webtransport_datagram(session, payload, opts \\ [])

Sends one HTTP DATAGRAM associated with the accepted WT session.

webtransport_info(arg1)

Returns the accepted WT session identity and maximum DATAGRAM payload.

webtransport_open(session, kind, opts \\ [])

Opens a session-associated WT stream; returns its QUIC stream ID as key.

webtransport_reset(session, key, code, opts \\ [])

Resets the send side with RESET_STREAM_AT, reliably delivering the WT prefix.

webtransport_send(session, key, bytes, fin, opts \\ [])

Writes raw WT stream bytes; FIN closes the send side.

webtransport_stop(session, key, code, opts \\ [])

Aborts the receive side with STOP_SENDING carrying a mapped application code.