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
| Name | Type | Description |
|---|---|---|
| lang_string | string | The raw Accept-Language HTTP header string to be parsed into individual language codes. |
Returns
| Type | Description |
|---|---|
tuple | A tuple of language codes parsed from the header, or an empty tuple if the header is malformed or exceeds length constraints without valid delimiters. |