view.core.body

Classes

BodyMixin(receive_data)

Mixin dataclass for common HTTP body operations.

Exceptions

BodyAlreadyUsedError()

The body was already used on this response.

InvalidJSONError(*msg)

The body is not valid JSON data or something went wrong when parsing it.

class BodyMixin(receive_data: Callable[[], AsyncIterator[bytes]])

Bases: object

Mixin dataclass for common HTTP body operations.

async body() bytes

Read the full body from the stream.

consumed: bool
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: Callable[[], AsyncIterator[bytes]]
async stream_body() AsyncIterator[bytes]

Incrementally stream the body, not keeping the whole thing in-memory at a given time.