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 BodyStream(IBodyStream): (source)
Constructor: BodyStream(interface, receive_or_protocol, max_body_size, max_buffer_size)
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__ |
Undocumented |
| Instance Variable | __body |
Undocumented |
| Instance Variable | __consumed |
Undocumented |
| Instance Variable | __is |
Undocumented |
| Instance Variable | __max |
Undocumented |
| Instance Variable | __max |
Undocumented |
| Instance Variable | __receive |
Undocumented |
| Property | is |
Return True when the full body has been cached by read(). |
| Property | is |
Return True when the raw transport stream has been consumed. |
Interface, receive_or_protocol: object, max_body_size: int | None = HTTPBodyLimits.max_body_size, *, max_buffer_size: int | None = HTTPBodyLimits.max_buffer_size):
(source)
¶
Initialize a BodyStream for the given transport interface.
| Parameters | |
interface:Interface | Transport protocol type (ASGI or RSGI). |
receiveobject | ASGI receive callable or RSGI HTTPProtocol instance. |
maxint | None, optional | Maximum allowed body size in bytes (default 16 MiB). An explicit None disables the transport limit for a manually built stream. |
maxint | None, optional | Maximum bytes buffered by read() (default 2 MiB). An explicit None disables this limit for a manually built stream. |
| Returns | |
None | Undocumented |
Buffer and return the full request body. Idempotent.
Subsequent calls return the cached buffer without re-reading the transport.
| Returns | |
bytes | Complete request body as a contiguous bytes object. |
| Raises | |
RuntimeError | If the stream was consumed by a streaming consumer without having been buffered first. |
PayloadTooLargeException | If the body exceeds max_body_size or max_buffer_size. |
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 | |
bytes | A chunk of the raw request body. |
| Raises | |
RuntimeError | If the stream was consumed by a streaming consumer (e.g. multipart) before the body was buffered. |
PayloadTooLargeException | If incoming data exceeds max_body_size. |
Return True when the full body has been cached by read().
| Returns | |
bool | True if the body has been fully buffered, False otherwise. |