Skip to main content

maybe_preferred_encoding_with_wildcard

Function maybe_preferred_encoding_with_wildcard 

pub fn maybe_preferred_encoding_with_wildcard(
    accepted: &[QualityValue<Encoding>],
    wildcard_quality: Option<Quality>,
    supported: impl SupportedEncodings,
) -> Option<Encoding>
Available on crate feature http only.
Expand description

Selects the preferred encoding while honoring the * wildcard per RFC 9110 §12.5.3.

accepted is the list of explicitly listed (and supported) encodings with their quality, as produced by parse_accept_encoding_headers. wildcard_quality is the quality of the * wildcard if present (see parse_accept_encoding_wildcard_quality). The wildcard quality applies to every supported encoding not explicitly listed.

Returns Some(encoding) (possibly Encoding::Identity) for the best acceptable encoding, or None when the client rejects every available representation (e.g. *;q=0 or a lone identity;q=0). A None result signals that the server should respond with 406 Not Acceptable.