Skip to main content

negotiated_http_version

Function negotiated_http_version 

pub fn negotiated_http_version(
    application_protocol: Option<&Protocol>,
    target_version: Option<Version>,
    fallback_version: Option<Version>,
    negotiated_alpn: Option<&ApplicationProtocol>,
    policy: Option<AlpnPolicy>,
) -> Result<Option<Version>, Box<dyn Error + Sync + Send>>
Available on crate feature tls only.
Expand description

Interpret negotiated ALPN for HTTP and validate the version policy.

An explicit target must match negotiated ALPN. The fallback is used only when ALPN is absent: strict policy requires ALPN if the target, or otherwise the fallback, selects HTTP/2 or HTTP/3. Without a policy override, only an explicit HTTP/3 target requires ALPN. Out-of-band agreement permits missing ALPN.

Returns None for absent ALPN without fabricating negotiated metadata, and for absent or non-HTTP application protocols. Unknown HTTP ALPN is rejected. The caller decides where to publish the returned version; a proxy tunnel’s negotiated version must not become the origin’s HTTP version.