module documentation

Undocumented

Constant RAISE​_ERROR Undocumented
Variable host​_validation​_re Undocumented
Class ​Http​Headers No class docstring; 0/2 constant, 1/2 method, 0/1 class method documented
Class ​Media​Type Undocumented
Function bytes​_to​_text Convert bytes objects to strings, using the given encoding. Illegally encoded input characters are replaced with Unicode "unknown" codepoint (�).
Function parse​_accept​_header Undocumented
Function split​_domain​_port Return a (domain, port) tuple from a given host.
Function validate​_host Validate the given host for this site.
RAISE_ERROR =

Undocumented

Value
object()
host_validation_re =

Undocumented

def bytes_to_text(s, encoding):

Convert bytes objects to strings, using the given encoding. Illegally encoded input characters are replaced with Unicode "unknown" codepoint (�).

Return any non-bytes objects without change.

def parse_accept_header(header):

Undocumented

def split_domain_port(host):

Return a (domain, port) tuple from a given host.

Returned domain is lowercased. If the host is invalid, the domain will be empty.

def validate_host(host, allowed_hosts):

Validate the given host for this site.

Check that the host looks valid and matches a host or host pattern in the given list of allowed_hosts. Any pattern beginning with a period matches a domain and all its subdomains (e.g. .example.com matches example.com and any subdomain), * matches anything, and anything else must match exactly.

Note: This function assumes that the given host is lowercased and has already had the port, if any, stripped off.

Return True for a valid host, False otherwise.