quart.wrappers.request module#

class quart.wrappers.request.Body(expected_content_length: int | None, max_content_length: int | None)#

Bases: object

A request body container.

The request body can either be iterated over and consumed in parts (without building up memory usage) or awaited.

async for data in body:
# or simply
complete = await body

Note: It is not possible to iterate over the data and then await it.

append(data: bytes) None#
clear() None#
set_complete() None#
set_result(data: bytes) None#

Convenience method, mainly for testing.

class quart.wrappers.request.Request(method: str, scheme: str, path: str, query_string: bytes, headers: Headers, root_path: str, http_version: str, scope: HTTPScope, *, max_content_length: int | None = None, body_timeout: int | None = None, send_push_promise: Callable[[str, Headers], Awaitable[None]])#

Bases: BaseRequestWebsocket

This class represents a request.

It can be subclassed and the subclassed used in preference by replacing the request_class with your subclass.


The class to store the body data within.


Can be overridden to implement a different form data parsing.


alias of Body

async close() None#
property data: bytes#
property files: MultiDict#

The parsed files.

This will return an empty multidict unless the request mimetype was enctype="multipart/form-data" and the method POST, PUT, or PATCH.

property form: MultiDict#

The parsed form encoded data.

Note file data is present in the files.


alias of FormDataParser

async get_data(cache: bool, as_text: Literal[False], parse_form_data: bool) bytes#
async get_data(cache: bool, as_text: Literal[True], parse_form_data: bool) str
async get_data(cache: bool = True, as_text: bool = False, parse_form_data: bool = False) AnyStr

Get the request body data.

  • cache – If False the body data will be cleared, resulting in any subsequent calls returning an empty AnyStr and reducing memory usage.

  • as_text – If True the data is returned as a decoded string, otherwise raw bytes are returned.

  • parse_form_data – Parse the data as form data first, return any remaining data.

async get_json(force: bool = False, silent: bool = False, cache: bool = True) Any#

Parses the body data as JSON and returns it.

  • force – Force JSON parsing even if the mimetype is not JSON.

  • silent – Do not trigger error handling if parsing fails, without this the on_json_loading_failed() will be called on error.

  • cache – Cache the parsed JSON on this request object.

property json: Any#

alias of Lock

make_form_data_parser() FormDataParser#
on_json_loading_failed(error: Exception) Any#

Handle a JSON parsing error.


error – The exception raised during parsing.


Any value returned (if overridden) will be used as the default for any get_json calls.

async send_push_promise(path: str) None#
property stream: NoReturn#
property values: CombinedMultiDict#