action0-req

Typed Python representations of HTTP requests and responses with convenient creation, duplication and manipulation — the companion of action0-url, which provides the URL representation.

uv add action0-req    # not on PyPI yet — install from GitHub for now

Highlights:

  • Header, Status and MethodStrEnum/IntEnum constants for the IANA-registered header field names, status codes (with reason phrases and category properties) and request methods.

  • Headers — an ordered, case-insensitive, multi-value aware mapping of HTTP header fields that preserves the representation exactly and redacts secret values in repr().

  • Request — method, URL, headers, body and HTTP version as plain attributes, with typed body accessors (body_bytes() / body_str() / body_producer()), copy() with overrides and a wire-format as_str().

  • Response — status (with reason phrase fallback and category properties), headers, body and an optional back-reference to the request, mirroring Request.

  • Streaming of request and response bodies via the BodyProducer protocol — sync and async (without blocking the event loop), with in-memory, file-backed and (async-)iterable-backed producers.

  • Fully typed (checked with mypy strict, pyright and ty), Python 3.11+, no runtime dependencies beyond action0-url.

The action0 namespace is simply the one the author likes to use for personal projects.