pub enum HttpVersionPolicy {
Http1Only,
Http2Only,
Http3Only,
Auto {
allow_http3: bool,
},
}Expand description
Policy controlling which HTTP protocol versions the client may negotiate.
The default is HttpVersionPolicy::Auto, which allows the client to
negotiate HTTP/2 via ALPN when available and fall back to HTTP/1.1
otherwise.
When the http2 feature is not enabled, only HttpVersionPolicy::Http1Only
is valid; attempting to use Http2Only or Auto without the http2
feature will result in an HTTP/1.1-only client at runtime.
When the http3 feature is enabled, HttpVersionPolicy::Http3Only
routes requests over QUIC using the h3 protocol. HTTP/3 uses a separate
transport (Quinn) and does not share connections with HTTP/1.1 or HTTP/2.
Variants§
Http1Only
Only HTTP/1.1 is permitted. The client will not advertise h2 in
ALPN and will not accept an HTTP/2 response.
Http2Only
Only HTTP/2 is permitted. The client advertises h2 via ALPN. If
the server does not negotiate HTTP/2, the connection fails.
Http3Only
Only HTTP/3 is permitted. The client uses QUIC via Quinn and the h3
protocol. Requires the http3 feature.
Auto
Allow negotiation. The client advertises both h2 and http/1.1
via ALPN and accepts whichever protocol the server selects.
When allow_http3 is true and the http3 feature is enabled,
HTTP/3 is also included in auto-negotiation. When allow_http3
is false, HTTP/3 is excluded; use Http3Only to explicitly
opt in.