class documentation
class _NameEncoder:
_NameEncoder converts HTTP header names to bytes
and canonicalizies their capitalization.
Method | __init__ |
Undocumented |
Method | encode |
Encode the name of a header (eg 'Content-Type') to an ISO-8859-1 bytestring if required. It will be canonicalized to Http-Header-Case. |
Class Variable | __slots__ |
Undocumented |
Constant | _MAX |
Undocumented |
Class Variable | _case |
A dict that maps conventionally-capitalized header names to their canonicalized representation, for headers with unconventional capitalization. |
Instance Variable | _canonical |
A dict that maps header names to their canonicalized representation. |
Encode the name of a header (eg 'Content-Type') to an ISO-8859-1 bytestring if required. It will be canonicalized to Http-Header-Case.
Parameters | |
name:str | bytes | An HTTP header name |
Returns | |
bytes | name, encoded if required, in Header-Case |
Raises | |
InvalidHeaderName | If the header name contains invalid characters like whitespace or NUL. |
A dict
that maps conventionally-capitalized header names to their canonicalized representation, for headers with unconventional capitalization.