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-Svcresponse header (H3Policy::observe_alt_svc, parsed byparse_alt_svc) or an HTTPS DNS record (H3Policy::observe_https_record). Each advertisement expires; a bounded table holds them. - Race at dial.
H3Policy::chooseanswersTransportChoice::Racefor 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
PathGenerationforUDP_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::chooseanswers 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_allowedrefuses every method: the contract permitsGETandHEADin 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
h3alternative from anAlt-Svcheader. - H3Endpoint
- Where an advertised HTTP/3 endpoint listens.
hostisNonewhen 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.
- Https
Record - The fields of an HTTPS (SVCB) DNS record the policy reads, as a resolver reports them.
- Window
Budget - The fixed memory a transport may spend on flow-control and socket windows.
Enums§
- AltSvc
- A parsed
Alt-Svcheader value. - TcpReason
- Why a request rides TCP.
- Transport
Choice - 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-Svcentry holds when it names noma(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-29and 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
methodmay ride TLS 1.3 early data. Never, in this build: the contract forbids it for every non-safe method and only permits it forGETandHEAD, which this client does not take. - parse_
alt_ svc - Parse an
Alt-Svcheader value (RFC 7838 §3), keeping onlyh3alternatives. - size_
window - The window for one of
connectionsconnections carryingbandwidthbytes per second over a round trip ofrtt: 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 allconnectionsnever sum pastWindowBudget::total.