Skip to main content

Module h3

Module h3 

Source
Expand description

The opportunistic HTTP/3 policy (networking doc, HTTP Transport).

HTTP/3 is an optimization the client may take, never a property the protocol depends on. This module is the whole of the decision the SDK makes about it, as plain values over an injected MonotonicClock so every rule is a deterministic unit test:

  • Discovery. The client learns of an HTTP/3 endpoint only from an Alt-Svc response header (H3Policy::observe_alt_svc, parsed by parse_alt_svc) or an HTTPS DNS record (H3Policy::observe_https_record). Each advertisement expires; a bounded table holds them.
  • Race at dial. H3Policy::choose answers TransportChoice::Race for an origin with a live advertisement on a network whose UDP is not known to be unusable. The race is between connection attempts, never between requests: a request rides exactly one dialed connection.
  • Per-network “UDP unusable” record. A QUIC dial that fails while TCP succeeds, a race in which both dials fail, or a QUIC path that stops making progress, records UDP as unusable on that PathGeneration for UDP_UNUSABLE_TTL (H3Policy::record_udp_unusable). A new path starts with no record.
  • Fallback at a request boundary. The choice is taken once, when a request starts. A request already riding QUIC is never moved mid-flight: it fails, the retry engine re-sends it, and the re-send’s H3Policy::choose answers TCP. Resume reads server truth, so the switch costs at most the bytes in flight.
  • No connection migration. Nothing here keys on a QUIC connection; a new path generation drops pooled connections (super::path::GenerationPool) exactly as it does for TCP.
  • No early data. early_data_allowed refuses every method: the contract permits GET and HEAD in TLS 1.3 early data, and this build takes none of it.
  • Windows cover the bandwidth-delay product within a fixed memory budget (size_window).

Only a build with the off-by-default http3 cargo feature races: it compiles the transport adapter that consumes this policy (transport, over quinn, h3 and h3-quinn), and H3Policy::for_build is capable there and incapable everywhere else. The SDK’s reqwest clients stay pinned to HTTP/1.1 (super::http_builder) in every build; under http3 their requests are routed through the transport (route), whose TCP leg is that same client (tcp_leg).

Structs§

AltService
One h3 alternative from an Alt-Svc header.
H3Endpoint
Where an advertised HTTP/3 endpoint listens. host is None when the advertisement names only a port (":443"), meaning the origin’s own host.
H3Policy
The opportunistic HTTP/3 decision: what has been advertised, which networks have unusable UDP, and what the next request should dial.
HttpsRecord
The fields of an HTTPS (SVCB) DNS record the policy reads, as a resolver reports them.
WindowBudget
The fixed memory a transport may spend on flow-control and socket windows.

Enums§

AltSvc
A parsed Alt-Svc header value.
TcpReason
Why a request rides TCP.
TransportChoice
How the next request to an origin is dialed. Taken once, when the request starts.
UdpFailure
Why UDP was recorded unusable on a network.

Constants§

ALT_SVC_DEFAULT_MAX_AGE
How long an Alt-Svc entry holds when it names no ma (RFC 7838 §3.1: 24 hours).
ALT_SVC_MAX_AGE_CAP
The longest any advertisement is believed, whatever it claims, so a stale endpoint cannot be pinned for days.
DEFAULT_WINDOW_BUDGET
64 KiB floor, 32 MiB across every connection.
H3_ALPN
The ALPN protocol id an advertisement must carry. Draft ids (h3-29 and earlier) are ignored.
MAX_ADVERTISED_ORIGINS
The most origins whose advertisement is held at once; the soonest to expire is evicted first.
MAX_UDP_RECORDS
The most networks whose “UDP unusable” record is held at once; the oldest path is evicted first.
UDP_UNUSABLE_TTL
How long a network keeps its “UDP unusable” record before QUIC is tried on it again.

Functions§

early_data_allowed
Whether a request with method may ride TLS 1.3 early data. Never, in this build: the contract forbids it for every non-safe method and only permits it for GET and HEAD, which this client does not take.
parse_alt_svc
Parse an Alt-Svc header value (RFC 7838 §3), keeping only h3 alternatives.
size_window
The window for one of connections connections carrying bandwidth bytes per second over a round trip of rtt: the bandwidth-delay product, cut to the connection’s equal share of the budget, and raised to the floor only where that share allows it. The windows of all connections never sum past WindowBudget::total.