tools2075%python.module
fault.internet

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
import

resolve_backslashes280%
function
bytes

resolve_backslashes(field)

Properly resolve backslashes inside quoted-string areas.

http_separators0
data

http_separators = b'()<>@,;:\\\"/[]?={} \t\x7f' + bytes(range(32))

tmap0
data

tmap = bytearray(range(256))

_quote1318%
function

_quote(octets)

quote0
function

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%
function

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%
function

_normal_parameter_area(more)

_normal_mediarange_area0
function

_normal_mediarange_area(more)

split_parameter_series387%
function

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
function

decode_parameters(sequence)

encode_parameters0
function

encode_parameters(sequence)