Collection of parsers and formatters that apply to multiple protocols.
Generally, a supplement for http, and a dependency of media. The tokenization that occurs in http is intentionally simple, but some of the unparsed fields may need to be structured by the downstream of a tokenization instance. Notably, cookie headers make use of parameter series that can be processed by split_parameter_series.
References
itertools
resolve_backslashes280%bytes
resolve_backslashes(field)
Properly resolve backslashes inside quoted-string areas.
http_separators0
http_separators = b'()<>@,;:\\\"/[]?={} \t\x7f' + bytes(range(32))
tmap0
tmap = bytearray(range(256))
_quote1318%
_quote(octets)
quote0
quote(octets)
Discover whether the octets should be quoted and backslash-escape any octets cited as needing escapes. quote is fairly expensive and should be avoided when possible. Given the case that it is known ahead of time that a quotation is unnecessary, join_parameter_series.Parameters.quote provided.
join_parameter_series180%
join_parameter_series(fields)
Given an iterator of key-value pairs, construct a properly escaped parameters series that is commonly used within HTTP headers.
The quote parameter is provided in order to override the escape mechanism given the case that it is known that no escaping need happen.
_normal_parameter_area166%
_normal_parameter_area(more)
_normal_mediarange_area0
_normal_mediarange_area(more)
split_parameter_series387%
split_parameter_series(series)
Given a series of ; separated of key-value pairs, return the sequence of key value pairs parsing quoted-string ranges properly.
Specification designated invalid character sequences are not checked, and must be handled separately for strict conformance.
decode_parameters0
decode_parameters(sequence)
encode_parameters0
encode_parameters(sequence)