Skip to main content

parse_accept_lang_header

Parse the value of the Accept-Language header up to a maximum length.

def parse_accept_lang_header(
lang_string: string
) - > tuple

Parse the value of the Accept-Language header up to a maximum length. The value of the header is truncated to a maximum length to avoid potential denial of service and memory exhaustion attacks. Excessive memory could be used if the raw value is very large as it would be cached due to the use of functools.lru_cache() to avoid repetitive parsing of common header values.

Parameters

NameTypeDescription
lang_stringstringThe raw Accept-Language HTTP header string to be parsed into individual language codes.

Returns

TypeDescription
tupleA tuple of language codes parsed from the header, or an empty tuple if the header is malformed or exceeds length constraints without valid delimiters.