ORIONIS API REFERENCE

THE ORIONIS API

Build with clarity.

Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.

class documentation

Parse and expose HTTP headers with case-insensitive lookup.

Class Method _fromRSGI Index grouped RSGI headers while normalizing each name once.
Method __contains__ Check whether the given header key is present.
Method __getitem__ Return the last value for the given header key.
Method __init__ Initialize Headers from an iterable of key-value pairs.
Method __iter__ Iterate over all header key-value pairs.
Method __len__ Return the total number of header entries.
Method __repr__ Return the canonical string representation of this instance.
Method byteItems Yield all header pairs as UTF-8 encoded byte strings.
Method count Return the number of occurrences of a header name.
Method get Return the last value for the given header key.
Method getAll Return all values for a key, or a mapping of all headers.
Method hasInvalidFormat Report whether any header contains a carriage return or newline.
Method items Return a copy of all header key-value pairs.
Method keys Return the set of unique header names.
Method values Return all header values in insertion order.
Class Variable __slots__ Declare the instance attribute slots reserved by this class.
Instance Variable _has_invalid_format Has invalid format supplied through invalid.
Instance Variable _index Lookup index used to resolve registered entries.
Instance Variable _items Items supplied through items.
def _fromRSGI(cls: type[Self], raw: RSGIHeaders) -> Self: (source)

Index grouped RSGI headers while normalizing each name once.

Parameters
raw:granian.rsgi.HeadersTransport collection exposing header names and get_all values.
Returns
typing.SelfHeaders retaining duplicate order, owned lists and CRLF validation.
def __contains__(self: Self, key: str) -> bool: (source)

Check whether the given header key is present.

Parameters
key:strCase-insensitive header name to check.
Returns
boolTrue if at least one entry matches, False otherwise.
def __getitem__(self: Self, key: str) -> str: (source)

Return the last value for the given header key.

Parameters
key:strCase-insensitive header name to retrieve.
Returns
strLast value associated with the key.
Raises
KeyErrorIf the header key is not found.
def __init__(self: Self, raw: Iterable[tuple[str, str]] | Iterable[tuple[bytes, bytes]], *, decode: bool = False): (source)

Initialize Headers from an iterable of key-value pairs.

Parameters
raw:Iterable[tuple[str, str]] | Iterable[tuple[bytes, bytes]]Iterable of (header_name, header_value) pairs.
decode:bool, optionalDecode transport byte pairs using Latin-1 before indexing.
Returns
NoneInitialize Headers from an iterable of key-value pairs.
def __iter__(self: Self) -> Iterator[tuple[str, str]]: (source)

Iterate over all header key-value pairs.

Returns
collections.abc.Iterator[tuple[str, str]]An iterator over (name, value) pairs.
def __len__(self: Self) -> int: (source)

Return the total number of header entries.

Returns
intNumber of (name, value) pairs stored.
def __repr__(self: Self) -> str: (source)

Return the canonical string representation of this instance.

Returns
strUnambiguous representation showing all stored header pairs.
def byteItems(self: Self) -> Iterator[tuple[bytes, bytes]]: (source)

Yield all header pairs as UTF-8 encoded byte strings.

Returns
collections.abc.Iterator[tuple[bytes, bytes]]Each (name, value) pair encoded as UTF-8 bytes.
def count(self: Self, key: str) -> int: (source)

Return the number of occurrences of a header name.

Parameters
key:strCase-insensitive header name.
Returns
intNumber of entries for the name.
def get(self: Self, key: str, default: str | None = None) -> str | None: (source)

Return the last value for the given header key.

Parameters
key:strCase-insensitive header name to look up.
default:str | None, optionalValue returned when the key is absent (default None).
Returns
str | NoneLast matching value, or default if not found.
def getAll(self: Self, key: str | None = None) -> dict[str, list[str]] | list[str]: (source)

Return all values for a key, or a mapping of all headers.

Parameters
key:str | None, optionalHeader name to look up. When None, returns a dict mapping every lowercase header name to its values.
Returns
dict[str, list[str]] | list[str]
  • dict[str, list[str]] - All headers grouped by name when key is None.
  • list[str] - Ordered list of values for the specified header, or an empty list when the header is absent.
def hasInvalidFormat(self: Self) -> bool: (source)

Report whether any header contains a carriage return or newline.

Returns
boolWhether the immutable input contains a CRLF injection marker.
def items(self: Self) -> list[tuple[str, str]]: (source)

Return a copy of all header key-value pairs.

Returns
list[tuple[str, str]]All (name, value) pairs in insertion order.
def keys(self: Self) -> set[str]: (source)

Return the set of unique header names.

Returns
set[str]All unique header names in their original casing.
def values(self: Self) -> list[str]: (source)

Return all header values in insertion order.

Returns
list[str]All header values as a list.
__slots__: tuple[str, ...] = (source)

Declare the instance attribute slots reserved by this class.

_has_invalid_format = (source)

Has invalid format supplied through invalid.

Lookup index used to resolve registered entries.

Items supplied through items.