view.core.body¶
The implementation of request and response bodies.
Classes
|
Mixin dataclass for common HTTP body operations. |
Exceptions
|
The body was already used on this response. |
|
The body is not valid JSON data or something went wrong when parsing it. |
- exception BodyAlreadyUsedError(receive_data: AsyncIterator[bytes])¶
Bases:
ViewErrorThe body was already used on this response.
Generally, this means that the same response object was executed multiple times.
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class BodyMixin(receive_data: AsyncIterator[bytes])¶
Bases:
objectMixin dataclass for common HTTP body operations.
- async json(*, parse_function: ~collections.abc.Callable[[str], dict[str, ~typing.Any]] = <function loads>) dict[str, Any]¶
Read the body as JSON data.
- receive_data: AsyncIterator[bytes]¶
- async stream_body() AsyncIterator[bytes]¶
Incrementally stream the body without keeping the whole thing in-memory at a given time.
- exception InvalidJSONError(*msg: str)¶
Bases:
ViewErrorThe body is not valid JSON data or something went wrong when parsing it.
If this occurred when parsing the body for a request, the fix is usually to reraise this with an error 400 (Bad Request).
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.