request#

class starlite.connection.request.Request#

Bases: Generic[User, Auth], ASGIConnection[HTTPRouteHandler, User, Auth]

The Starlite Request class.

__init__(scope: Scope, receive: Receive = <function empty_receive>, send: Send = <function empty_send>) None#

Initialize Request.

Parameters:
  • scope – The ASGI connection scope.

  • receive – The ASGI receive function.

  • send – The ASGI send function.

property method: Method#

Return the request method.

Returns:

The request Method

property content_type: Tuple[str, Dict[str, str]]#

Parse the request’s ‘Content-Type’ header, returning the header value and any options as a dictionary.

Returns:

A tuple with the parsed value and a dictionary containing any options send in it.

async json() Any#

Retrieve the json request body from the request.

Returns:

An arbitrary value

async msgpack() Any#

Retrieve the MessagePack request body from the request.

Returns:

An arbitrary value

async stream() AsyncGenerator[bytes, None]#

Return an async generator that streams chunks of bytes.

Returns:

An async generator.

Raises:

RuntimeError – if the stream is already consumed

async body() bytes#

Return the body of the request.

Returns:

A byte-string representing the body of the request.

async form() FormMultiDict#

Retrieve form data from the request. If the request is either a ‘multipart/form-data’ or an ‘application/x-www-form- urlencoded’, return a FormMultiDict instance populated with the values sent in the request, otherwise, an empty instance.

Returns:

A FormMultiDict instance

async send_push_promise(path: str) None#

Send a push promise.

This method requires the http.response.push extension to be sent from the ASGI server.

Parameters:

path – Path to send the promise to.

Returns:

None