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 a multipart byte stream into form fields and uploaded files.

Method __init__ Initialize a new MultipartStreamParser instance.
Async Method _advanceState Advance the parser according to the current state.
Method _closeFailedParts Close every failed upload before error reporting can be cancelled.
Method _closeRejectedPart Close a rejected upload and report cleanup failures.
Async Method _consumeBody Consume a body segment and advance the parser to the next state.
Method _delimiterEnd Resolve the end of a multipart delimiter line.
Method _discardPrefix Discard consumed bytes and realign the delimiter padding cursor.
Method _findBoundary Find a complete multipart delimiter or an incomplete suffix.
Async Method _finishPart Finalize a part body or decode transfer-encoded file content.
Method _newPart Create a multipart part from the parsed MIME headers.
Async Method _parseParts Parse all parts until the multipart stream ends or fails.
Method _readHeaders Read a complete MIME header block for the next multipart part.
Async Method _receiveChunk Read the next chunk from the stream and track end-of-stream.
Method _searchBoundary Search for the next multipart boundary and decide the parser state.
Async Method _writePart Write a buffer prefix into the active part and enforce size limits.
Async Method parse Parse the multipart stream and return the collected form data.
Class Variable __slots__ Declare the instance attribute slots reserved by this class.
Instance Variable _atStart At start flag used by MultipartStreamParser.
Instance Variable _currentPart Multipart part currently receiving parsed headers or body bytes.
Instance Variable _eof Eof flag used by MultipartStreamParser.
Instance Variable _headerSearch Header search value used by MultipartStreamParser.
Instance Variable _memorySize Memory size value used by MultipartStreamParser.
Instance Variable _paddingEnd Padding end value used by MultipartStreamParser.
Instance Variable _paddingStart Position at which multipart boundary padding begins.
Instance Variable _partMemorySize Part memory size value used by MultipartStreamParser.
Instance Variable _pendingChunk Pending chunk value used by MultipartStreamParser.
Instance Variable _pendingOffset Pending offset value used by MultipartStreamParser.
Instance Variable _totalSize Total size value used by MultipartStreamParser.
Instance Variable boundary Raw multipart boundary token (without leading --).
Instance Variable buffer Allocate the working buffer for incoming byte chunks.
Instance Variable current_part_size Current part size value used by MultipartStreamParser.
Instance Variable fields_count Fields count value used by MultipartStreamParser.
Instance Variable files_count Initialize runtime counters to zero.
Instance Variable max_body_size Maximum transport bytes, including preamble and epilogue (16 MiB).
Instance Variable max_field_size Maximum raw bytes of a single text field (default 1 MiB).
Instance Variable max_fields Maximum number of field parts accepted (default 128).
Instance Variable max_files Maximum number of file parts accepted (default 32).
Instance Variable max_header_size Maximum byte size of the MIME headers for each part (default 16 KiB).
Instance Variable max_memory_size Retained field/file memory budget (default 8 MiB), excluding transport buffers, object metadata and temporary copies.
Instance Variable max_part_size Maximum byte size of a single part (default 10 MiB).
Instance Variable memory_threshold Bytes before a file part spills to disk (default 256 KiB).
Instance Variable stream Async byte stream produced by the transport layer.
def __init__(self, stream: AsyncIterable[bytes], boundary: bytes, *, max_files: int = _DEFAULT_LIMITS['max_files'], max_fields: int = _DEFAULT_LIMITS['max_fields'], max_part_size: int = _DEFAULT_LIMITS['max_part_size'], memory_threshold: int = _DEFAULT_LIMITS['memory_threshold'], max_header_size: int = _DEFAULT_LIMITS['max_header_size'], max_body_size: int = _DEFAULT_LIMITS['max_body_size'], max_field_size: int = _DEFAULT_LIMITS['max_field_size'], max_memory_size: int = _DEFAULT_LIMITS['max_memory_size']): (source)

Initialize a new MultipartStreamParser instance.

Parameters
stream:collections.abc.AsyncIterable[bytes]Async byte stream produced by the transport layer.
boundary:bytesRaw multipart boundary token (without leading --).
max_files:int, optionalMaximum number of file parts accepted (default 32).
max_fields:int, optionalMaximum number of field parts accepted (default 128).
max_part_size:int, optionalMaximum byte size of a single part (default 10 MiB).
memory_threshold:int, optionalBytes before a file part spills to disk (default 256 KiB).
max_header_size:int, optionalMaximum byte size of the MIME headers for each part (default 16 KiB).
max_body_size:int, optionalMaximum transport bytes, including preamble and epilogue (16 MiB).
max_field_size:int, optionalMaximum raw bytes of a single text field (default 1 MiB).
max_memory_size:int, optionalRetained field/file memory budget (default 8 MiB), excluding transport buffers, object metadata and temporary copies.
Returns
NoneInitialize a new MultipartStreamParser instance.
async def _advanceState(self, state: int, current_part: MultipartPart | None, form_items: list[tuple[str, object]], body_marker: bytes, tail_size: int) -> tuple[int, MultipartPart | None, bool]: (source)

Advance the parser according to the current state.

Parameters
state:intCurrent parser state.
current_part:orionis.http.payload.part.MultipartPart | NoneCurrent part being streamed.
form_items:list[tuple[str, object]]Accumulated form values collected so far.
body_marker:bytesBoundary marker used to detect body terminations.
tail_size:intMinimum trailing bytes required to recognize an incomplete boundary.
Returns
tuple[int, orionis.http.payload.part.MultipartPart | None, bool]Next state, part pointer, and whether the loop should continue.
def _closeFailedParts(self, form_items: list[tuple[str, object]]) -> list[Exception]: (source)

Close every failed upload before error reporting can be cancelled.

Parameters
form_items:list[tuple[str, object]]Completed fields and uploads accumulated before the parse failure.
Returns
list[Exception]Cleanup errors in closure order, after attempting every owned file.
def _closeRejectedPart(self, part: MultipartPart, failure: BaseException): (source)

Close a rejected upload and report cleanup failures.

Parameters
part:orionis.http.payload.part.MultipartPartRejected multipart part; leave non-file parts untouched.
failure:BaseExceptionRejection error to report if cleanup fails and it is an Exception.
Returns
NoneClose the file data when the part represents an upload.
Raises
ExceptionIf file closure fails, after reporting the cleanup error.
async def _consumeBody(self, current_part: MultipartPart, form_items: list[tuple[str, object]], body_marker: bytes, tail_size: int) -> tuple[int, MultipartPart | None]: (source)

Consume a body segment and advance the parser to the next state.

Parameters
current_part:orionis.http.payload.part.MultipartPartPart being read from the incoming multipart stream.
form_items:list[tuple[str, object]]Accumulated form values collected so far.
body_marker:bytesBoundary marker used to detect the end of a body section.
tail_size:intMinimum trailing bytes required to recognize an incomplete boundary.
Returns
tuple[int, orionis.http.payload.part.MultipartPart | None]Parser state and the current part after processing the segment.
def _delimiterEnd(self, start: int) -> int: (source)

Resolve the end of a multipart delimiter line.

Parameters
start:intOffset where the boundary candidate begins.
Returns
intEnd offset for a complete delimiter, -1 for an incomplete one, or -2 for an invalid boundary.
def _discardPrefix(self, length: int): (source)

Discard consumed bytes and realign the delimiter padding cursor.

Parameters
length:intNumber of leading bytes to remove from the buffer.
Returns
NoneComplete the documented operation without returning a value.
def _findBoundary(self, marker: bytes) -> tuple[int, int]: (source)

Find a complete multipart delimiter or an incomplete suffix.

Parameters
marker:bytesBoundary sequence to search for in the active buffer.
Returns
tuple[int, int]Pair containing the delimiter start offset and its end offset.
async def _finishPart(self, part: MultipartPart) -> object: (source)

Finalize a part body or decode transfer-encoded file content.

Parameters
part:orionis.http.payload.part.MultipartPartPart whose content should be finalized.
Returns
objectFinalized value for the form field or uploaded file.
def _newPart(self, header_end: int) -> MultipartPart: (source)

Create a multipart part from the parsed MIME headers.

Parameters
header_end:intOffset where the header block ends within the buffer.
Returns
orionis.http.payload.part.MultipartPartInitialized multipart part with its metadata and body buffer.
async def _parseParts(self, form_items: list[tuple[str, object]]) -> FormData: (source)

Parse all parts until the multipart stream ends or fails.

Parameters
form_items:list[tuple[str, object]]Accumulated form values collected so far.
Returns
orionis.http.payload.form_data.FormDataParsed form data container for all field and file parts.
def _readHeaders(self) -> MultipartPart | None: (source)

Read a complete MIME header block for the next multipart part.

Returns
orionis.http.payload.part.MultipartPart | NoneThe initialized part when headers are complete, otherwise None.
async def _receiveChunk(self, stream: AsyncIterator[bytes]) -> bool: (source)

Read the next chunk from the stream and track end-of-stream.

Parameters
stream:collections.abc.AsyncIterator[bytes]Async byte stream providing incoming chunks.
Returns
boolTrue when more data is available, otherwise False.
def _searchBoundary(self, body_marker: bytes) -> int: (source)

Search for the next multipart boundary and decide the parser state.

Parameters
body_marker:bytesDelimiter sequence used to terminate a body segment.
Returns
intNext parser state to run.
async def _writePart(self, part: MultipartPart, length: int): (source)

Write a buffer prefix into the active part and enforce size limits.

Parameters
part:orionis.http.payload.part.MultipartPartCurrent multipart part being populated.
length:intNumber of bytes to append from the current buffer.
Returns
NoneComplete the documented operation without returning a value.
async def parse(self) -> FormData: (source)

Parse the multipart stream and return the collected form data.

Returns
orionis.http.payload.form_data.FormDataContainer with all parsed field values and uploaded files.
__slots__: tuple[str, ...] = (source)

Declare the instance attribute slots reserved by this class.

_atStart: bool = (source)

At start flag used by MultipartStreamParser.

Multipart part currently receiving parsed headers or body bytes.

Eof flag used by MultipartStreamParser.

_headerSearch = (source)

Header search value used by MultipartStreamParser.

_memorySize = (source)

Memory size value used by MultipartStreamParser.

_paddingEnd = (source)

Padding end value used by MultipartStreamParser.

_paddingStart = (source)

Position at which multipart boundary padding begins.

_partMemorySize: int = (source)

Part memory size value used by MultipartStreamParser.

_pendingChunk = (source)

Pending chunk value used by MultipartStreamParser.

_pendingOffset = (source)

Pending offset value used by MultipartStreamParser.

_totalSize: int = (source)

Total size value used by MultipartStreamParser.

boundary = (source)

Raw multipart boundary token (without leading --).

Allocate the working buffer for incoming byte chunks.

current_part_size: int = (source)

Current part size value used by MultipartStreamParser.

fields_count: int = (source)

Fields count value used by MultipartStreamParser.

files_count: int = (source)

Initialize runtime counters to zero.

max_body_size = (source)

Maximum transport bytes, including preamble and epilogue (16 MiB).

max_field_size = (source)

Maximum raw bytes of a single text field (default 1 MiB).

max_fields = (source)

Maximum number of field parts accepted (default 128).

max_files = (source)

Maximum number of file parts accepted (default 32).

max_header_size = (source)

Maximum byte size of the MIME headers for each part (default 16 KiB).

max_memory_size = (source)

Retained field/file memory budget (default 8 MiB), excluding transport buffers, object metadata and temporary copies.

max_part_size = (source)

Maximum byte size of a single part (default 10 MiB).

memory_threshold = (source)

Bytes before a file part spills to disk (default 256 KiB).

Async byte stream produced by the transport layer.