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 MultipartStreamParser(IMultipartStreamParser): (source)
Constructor: MultipartStreamParser(stream, boundary, max_files, max_fields, ...)
Parse a multipart byte stream into form fields and uploaded files.
| Method | __init__ |
Initialize a new MultipartStreamParser instance. |
| Async Method | _advance |
Advance the parser according to the current state. |
| Async Method | _consume |
Consume a body segment and advance the parser to the next state. |
| Method | _delimiter |
Resolve the end of a multipart delimiter line. |
| Method | _discard |
Discard consumed bytes and realign the delimiter padding cursor. |
| Method | _find |
Find a complete multipart delimiter or an incomplete suffix. |
| Async Method | _finish |
Finalize a part body or decode transfer-encoded file content. |
| Method | _new |
Create a multipart part from the parsed MIME headers. |
| Async Method | _parse |
Parse all parts until the multipart stream ends or fails. |
| Method | _read |
Read a complete MIME header block for the next multipart part. |
| Async Method | _receive |
Read the next chunk from the stream and track end-of-stream. |
| Method | _search |
Search for the next multipart boundary and decide the parser state. |
| Async Method | _write |
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__ |
Undocumented |
| Instance Variable | _at |
Undocumented |
| Instance Variable | _current |
Undocumented |
| Instance Variable | _eof |
Undocumented |
| Instance Variable | _header |
Undocumented |
| Instance Variable | _memory |
Undocumented |
| Instance Variable | _padding |
Undocumented |
| Instance Variable | _padding |
Undocumented |
| Instance Variable | _part |
Undocumented |
| Instance Variable | _pending |
Undocumented |
| Instance Variable | _pending |
Undocumented |
| Instance Variable | _total |
Undocumented |
| Instance Variable | boundary |
Undocumented |
| Instance Variable | buffer |
Undocumented |
| Instance Variable | current |
Undocumented |
| Instance Variable | fields |
Undocumented |
| Instance Variable | files |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | memory |
Undocumented |
| Instance Variable | stream |
Undocumented |
AsyncIterable[ bytes], boundary: bytes, *, max_files: int = HTTPBodyLimits.max_files, max_fields: int = HTTPBodyLimits.max_fields, max_part_size: int = HTTPBodyLimits.max_part_size, memory_threshold: int = HTTPBodyLimits.memory_threshold, max_header_size: int = HTTPBodyLimits.max_header_size, max_body_size: int = HTTPBodyLimits.max_body_size, max_field_size: int = HTTPBodyLimits.max_field_size, max_memory_size: int = HTTPBodyLimits.max_memory_size):
(source)
¶
Initialize a new MultipartStreamParser instance.
| Parameters | |
stream:AsyncIterable[bytes] | Async byte stream produced by the transport layer. |
boundary:bytes | Raw multipart boundary token (without leading --). |
maxint, optional | Maximum number of file parts accepted (default 32). |
maxint, optional | Maximum number of field parts accepted (default 128). |
maxint, optional | Maximum byte size of a single part (default 10 MiB). |
memoryint, optional | Bytes before a file part spills to disk (default 256 KiB). |
maxint, optional | Maximum byte size of the MIME headers for each part (default 16 KiB). |
maxint, optional | Maximum transport bytes, including preamble and epilogue (16 MiB). |
maxint, optional | Maximum raw bytes of a single text field (default 1 MiB). |
maxint, optional | Retained field/file memory budget (default 8 MiB), excluding transport buffers, object metadata and temporary copies. |
| Returns | |
None | Undocumented |
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:int | Current parser state. |
currentMultipartPart | None | Current part being streamed. |
formlist[tuple[str, object]] | Accumulated form values collected so far. |
bodybytes | Boundary marker used to detect body terminations. |
tailint | Minimum trailing bytes required to recognize an incomplete boundary. |
| Returns | |
tuple[int, MultipartPart | None, bool] | Next state, part pointer, and whether the loop should continue. |
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 | |
currentMultipartPart | Part being read from the incoming multipart stream. |
formlist[tuple[str, object]] | Accumulated form values collected so far. |
bodybytes | Boundary marker used to detect the end of a body section. |
tailint | Minimum trailing bytes required to recognize an incomplete boundary. |
| Returns | |
tuple[int, MultipartPart | None] | Parser state and the current part after processing the segment. |
Finalize a part body or decode transfer-encoded file content.
| Parameters | |
part:MultipartPart | Part whose content should be finalized. |
| Returns | |
object | Finalized value for the form field or uploaded file. |
Create a multipart part from the parsed MIME headers.
| Parameters | |
headerint | Offset where the header block ends within the buffer. |
| Returns | |
MultipartPart | Initialized multipart part with its metadata and body buffer. |
Read a complete MIME header block for the next multipart part.
| Returns | |
MultipartPart | None | The initialized part when headers are complete, otherwise None. |
Read the next chunk from the stream and track end-of-stream.
| Parameters | |
stream:AsyncIterator[bytes] | Async byte stream providing incoming chunks. |
| Returns | |
bool | True when more data is available, otherwise False. |
Write a buffer prefix into the active part and enforce size limits.
| Parameters | |
part:MultipartPart | Current multipart part being populated. |
length:int | Number of bytes to append from the current buffer. |
| Returns | |
None | Complete the documented operation without returning a value. |
Parse the multipart stream and return the collected form data.
| Returns | |
FormData | Container with all parsed field values and uploaded files. |