Skip to main content

parse_header_parameters

Parse a Content-type like header. Return the main content-type and a dictionary of options.

If line is longer than max_length, ValueError is raised.

def parse_header_parameters(
line: string,
max_length: integer = MAX_HEADER_LENGTH
) - > tuple

Parse a Content-type like header. Return the main content-type and a dictionary of options. If line is longer than max_length, ValueError is raised.

Parameters

NameTypeDescription
linestringThe raw header string to be parsed, typically from a Content-Type or Content-Disposition header.
max_lengthinteger = MAX_HEADER_LENGTHThe maximum allowed length of the input string to prevent resource exhaustion; defaults to a predefined system limit.

Returns

TypeDescription
tupleA tuple containing the main content-type as a lowercase string and a dictionary of parsed parameters and their values.