Skip to main content

parse_accept_language

Function parse_accept_language 

Source
pub fn parse_accept_language(header: Option<&str>) -> Option<String>
Expand description

Parse an Accept-Language header value, returning the first language tag that passes the validator. Pulled out as a free function so the negotiation policy is unit-testable without a Request.

Returns:

  • Some(tag) when the header contains at least one valid tag. Validation: ASCII letters / digits / hyphens only, length 1..=[MAX_TAG_LEN].
  • None when the header is missing, empty after trimming, or contains no valid tag.