edri.api.headerkit package¶
Submodules¶
edri.api.headerkit.core module¶
- class edri.api.headerkit.core.Headers(raw: ~collections.abc.Iterable[tuple[bytes, bytes]], *, registry: ~edri.api.headerkit.registry.Registry | None = None, policy: ~edri.api.headerkit.policy.HeaderPolicy = HeaderPolicy(mode=<ParseMode.STRICT: 'strict'>, unknown=<UnknownHeaderMode.RAW: 'raw'>, max_total_bytes=65536, max_field_lines=256, allow_obs_text=True, strip_ows=True), http_version: str = '1.1')[source]¶
Bases:
objectLossless, lazy, typed HTTP header accessor for ASGI scopes.
The object keeps the original ASGI byte pairs intact while indexing by lowercase header name. Semantic parsing is opt-in and lazy through the registry.
- property accept_encoding: tuple[Any, ...]¶
- property accept_language: tuple[Any, ...]¶
- property authorization: Authorization | None¶
- property cache_control: CacheControl¶
- property content_length: int | None¶
- property date: DateHeader | None¶
- classmethod from_scope(scope: ~collections.abc.Mapping[str, ~typing.Any], *, registry: ~edri.api.headerkit.registry.Registry | None = None, policy: ~edri.api.headerkit.policy.HeaderPolicy = HeaderPolicy(mode=<ParseMode.STRICT: 'strict'>, unknown=<UnknownHeaderMode.RAW: 'raw'>, max_total_bytes=65536, max_field_lines=256, allow_obs_text=True, strip_ows=True)) Headers[source]¶
- property host: str | None¶
- property if_none_match: EntityTagSet¶
edri.api.headerkit.defaults module¶
edri.api.headerkit.errors module¶
- exception edri.api.headerkit.errors.DuplicateHeader[source]¶
Bases:
HeaderErrorA header was repeated where the selected policy requires a singleton.
- exception edri.api.headerkit.errors.HeaderError[source]¶
Bases:
ValueErrorBase class for header parsing/access errors.
- exception edri.api.headerkit.errors.HeaderTooLarge[source]¶
Bases:
HeaderErrorThe configured aggregate header-size limit was exceeded.
- exception edri.api.headerkit.errors.InvalidHeader[source]¶
Bases:
HeaderErrorHeader name or value is syntactically invalid at the generic HTTP layer.
- exception edri.api.headerkit.errors.ParseError[source]¶
Bases:
HeaderErrorA semantically known header failed to parse.
edri.api.headerkit.grammar module¶
edri.api.headerkit.parsers module¶
edri.api.headerkit.policy module¶
- class edri.api.headerkit.policy.HeaderPolicy(mode: 'ParseMode' = <ParseMode.STRICT: 'strict'>, unknown: 'UnknownHeaderMode' = <UnknownHeaderMode.RAW: 'raw'>, max_total_bytes: 'int' = 65536, max_field_lines: 'int' = 256, allow_obs_text: 'bool' = True, strip_ows: 'bool' = True)[source]¶
Bases:
object
edri.api.headerkit.registry module¶
edri.api.headerkit.response module¶
- class edri.api.headerkit.response.ResponseHeaders(raw: Iterable[tuple[bytes, bytes]] = ())[source]¶
Bases:
objectBuilder for ASGI response header byte pairs.
It deliberately treats Set-Cookie as append-only and never coalesces it.
edri.api.headerkit.types module¶
- class edri.api.headerkit.types.AcceptItem(media: 'MediaType', q: 'float' = 1.0, accept_ext: 'Mapping[str, str] | None' = None, order: 'int' = 0)[source]¶
Bases:
object- property acceptable: bool¶
- property specificity: int¶
- property value: str¶
- class edri.api.headerkit.types.Authorization(scheme: 'str', credentials: 'str')[source]¶
Bases:
object
- class edri.api.headerkit.types.ByteRange(start: 'int | None', end: 'int | None')[source]¶
Bases:
object
- class edri.api.headerkit.types.CacheControl(directives: 'Mapping[str, str | bool]')[source]¶
Bases:
object- property max_age: int | None¶
- property no_cache: bool¶
- property no_store: bool¶
- class edri.api.headerkit.types.CombineMode(*values)[source]¶
Bases:
str,Enum- COMMA_LIST = 'comma-list'¶
- COOKIE = 'cookie'¶
- NEVER_COMBINE = 'never-combine'¶
- OPAQUE = 'opaque'¶
- SINGLETON = 'singleton'¶
- class edri.api.headerkit.types.Cookies(pairs: 'tuple[tuple[str, str], ...]')[source]¶
Bases:
object- dechunked() Cookies[source]¶
Reassemble Auth.js / NextAuth chunked cookies.
When a cookie value exceeds the ~4 KB browser limit, Auth.js splits it into
name.0,name.1, … and the browser sends each chunk back as a separate cookie. This rejoins a contiguous family starting at.0into a singlenamecookie (values concatenated in index order).A non-chunked cookie of the same base name takes precedence (its chunk siblings are then left untouched). Chunk families with a missing
.0or a gap keep their unconsumed members as literal cookies, so nothing is silently dropped.
- class edri.api.headerkit.types.EntityTagSet(any: 'bool', tags: 'tuple[EntityTag, ...]' = ())[source]¶
Bases:
object
- class edri.api.headerkit.types.Forwarded(elements: 'tuple[ForwardedElement, ...]')[source]¶
Bases:
object
- class edri.api.headerkit.types.MediaType(type: 'str', subtype: 'str', params: 'Mapping[str, str]')[source]¶
Bases:
object- property essence: str¶