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

Own and manage the raw HTTP request body stream.

Enforce the max-body-size limit and provide transparent replay when the body has already been buffered by read().

Notes

The underlying transport stream is consumed at most once. After read() completes, stream() replays the cached buffer so callers such as the multipart parser keep working even after a plain body() call. Calling stream() after a streaming consumer has iterated it—without a prior read()—raises RuntimeError. Raw bytes are gone after streaming multipart.

Method __init__ Initialize a BodyStream for the given transport interface.
Async Method read Buffer and return the full request body. Idempotent.
Async Method stream Yield body chunks from the transport.
Class Variable __slots__ Declare the instance attribute slots reserved by this class.
Instance Variable __body Initialize the body buffer to None (not yet read).
Instance Variable __consumed Track whether the raw transport stream has been consumed.
Instance Variable __is_rsgi Record which transport provides the body chunks.
Instance Variable __max_buffer_size Maximum bytes buffered by read() (default 2 MiB). An explicit None disables this limit for a manually built stream.
Instance Variable __max_size Maximum allowed body size in bytes (default 16 MiB). An explicit None disables the transport limit for a manually built stream.
Instance Variable __receive ASGI receive callable or RSGI HTTPProtocol instance.
Property isBuffered Return True when the full body has been cached by read().
Property isConsumed Return True when the raw transport stream has been consumed.
def __init__(self, interface: Interface, receive_or_protocol: object, max_body_size: int | None = _DEFAULT_LIMITS['max_body_size'], *, max_buffer_size: int | None = _DEFAULT_LIMITS['max_buffer_size']): (source)

Initialize a BodyStream for the given transport interface.

Parameters
interface:orionis.http.enums.InterfaceTransport protocol type (ASGI or RSGI).
receive_or_protocol:objectASGI receive callable or RSGI HTTPProtocol instance.
max_body_size:int | None, optionalMaximum allowed body size in bytes (default 16 MiB). An explicit None disables the transport limit for a manually built stream.
max_buffer_size:int | None, optionalMaximum bytes buffered by read() (default 2 MiB). An explicit None disables this limit for a manually built stream.
Returns
NoneInitialize a BodyStream for the given transport interface.
async def read(self) -> bytes: (source)

Buffer and return the full request body. Idempotent.

Subsequent calls return the cached buffer without re-reading the transport.

Returns
bytesComplete request body as a contiguous bytes object.
Raises
RuntimeErrorIf the stream was consumed by a streaming consumer without having been buffered first.
orionis.http.payload.body.PayloadTooLargeExceptionIf the body exceeds max_body_size or max_buffer_size.
async def stream(self) -> AsyncGenerator[bytes]: (source)

Yield body chunks from the transport.

Replay the internal buffer as a single chunk when read() was called first, making this method safe to call multiple times.

Yields
bytesA chunk of the raw request body.
Raises
RuntimeErrorIf the stream was consumed by a streaming consumer (e.g. multipart) before the body was buffered.
ConnectionErrorIf the ASGI client disconnects before the final request-body frame.
orionis.http.payload.body.PayloadTooLargeExceptionIf incoming data exceeds max_body_size.
__slots__: tuple[str, ...] = (source)

Declare the instance attribute slots reserved by this class.

Initialize the body buffer to None (not yet read).

__consumed: bool = (source)

Track whether the raw transport stream has been consumed.

__is_rsgi: bool = (source)

Record which transport provides the body chunks.

__max_buffer_size = (source)

Maximum bytes buffered by read() (default 2 MiB). An explicit None disables this limit for a manually built stream.

__max_size = (source)

Maximum allowed body size in bytes (default 16 MiB). An explicit None disables the transport limit for a manually built stream.

__receive = (source)

ASGI receive callable or RSGI HTTPProtocol instance.

Return True when the full body has been cached by read().

Returns
boolTrue if the body has been fully buffered, False otherwise.

Return True when the raw transport stream has been consumed.

Returns
boolTrue if the transport stream has been iterated, False otherwise.