Module

http.headers

Immutable, case-insensitive HTTP headers.

ImplementsMapping[str, str] and the MultiValueMappingprotocol. Stores raw byte pairs from the ASGI scope; decodes on access.

Classes

Headers 9
Immutable, case-insensitive HTTP headers. ``__getitem__`` returns the first matching value. ``get_…

Immutable, case-insensitive HTTP headers.

__getitem__returns the first matching value. get_list returns all values for a header (e.g. multiple Set-Cookie).

Methods

raw 0 tuple[tuple[bytes, bytes…
Access raw header byte pairs for ASGI compatibility.
property
def raw(self) -> tuple[tuple[bytes, bytes], ...]
Returns
tuple[tuple[bytes, bytes], ...]
get 2 str | None
Return the first value for *key*, or *default* if missing.
def get(self, key: str, default: str | None = None) -> str | None
Parameters
Name Type Description
key
default Default:None
Returns
str | None
get_list 1 list[str]
Return all values for *key* (e.g. multiple ``Set-Cookie``).
def get_list(self, key: str) -> list[str]
Parameters
Name Type Description
key
Returns
list[str]
Internal Methods 6
__init__ 1
def __init__(self, raw: tuple[tuple[bytes, bytes], ...] = ()) -> None
Parameters
Name Type Description
raw Default:()
__getitem__ 1 str
def __getitem__(self, key: str) -> str
Parameters
Name Type Description
key
Returns
str
__contains__ 1 bool
def __contains__(self, key: object) -> bool
Parameters
Name Type Description
key
Returns
bool
__iter__ 0 Iterator[str]
def __iter__(self) -> Iterator[str]
Returns
Iterator[str]
__len__ 0 int
def __len__(self) -> int
Returns
int
__repr__ 0 str
def __repr__(self) -> str
Returns
str