web_request

Module Contents

Classes

FileField()
BaseRequest(self,message,payload,protocol,payload_writer,task,loop)
Request(self,*args,**kwargs)
class FileField
class BaseRequest(message, payload, protocol, payload_writer, task, loop)
__init__(message, payload, protocol, payload_writer, task, loop)
clone()

Clone itself with replacement some attributes.

Creates and returns a new instance of Request object. If no parameters are given, an exact copy is returned. If a parameter is not passed, it will reuse the one from the current request object.

task()
protocol()
transport()
writer()
message()
rel_url()
loop()
__getitem__(key)
__setitem__(key, value)
__delitem__(key)
__len__()
__iter__()
secure()

A bool indicating if the request is handled with SSL.

forwarded()

A tuple containing all parsed Forwarded header(s).

Makes an effort to parse Forwarded headers as specified by RFC 7239:

  • It adds one (immutable) dictionary per Forwarded ‘field-value’, ie per proxy. The element corresponds to the data in the Forwarded field-value added by the first proxy encountered by the client. Each subsequent item corresponds to those added by later proxies.
  • It checks that every value has valid syntax in general as specified in section 4: either a ‘token’ or a ‘quoted-string’.
  • It un-escapes found escape sequences.
  • It does NOT validate ‘by’ and ‘for’ contents as specified in section 6.
  • It does NOT validate ‘host’ contents (Host ABNF).
  • It does NOT validate ‘proto’ contents for valid URI scheme names.

Returns a tuple containing one or more immutable dicts

scheme()

A string representing the scheme of the request.

Hostname is resolved in this order:

  • overridden value by .clone(scheme=new_scheme) call.
  • type of connection to peer: HTTPS if socket is SSL, HTTP otherwise.

‘http’ or ‘https’.

method()

Read only property for getting HTTP method.

The value is upper-cased str like ‘GET’, ‘POST’, ‘PUT’ etc.

version()

Read only property for getting HTTP version of request.

Returns aiohttp.protocol.HttpVersion instance.

host()

Hostname of the request.

Hostname is resolved in this order:

  • overridden value by .clone(host=new_host) call.
  • HOST HTTP header
  • socket.getfqdn() value
remote()

Remote IP of client initiated HTTP request.

The IP is resolved in this order:

  • overridden value by .clone(remote=new_remote) call.
  • peername of opened socket
url()
path()

The URL including PATH INFO without the host or scheme.

E.g., /app/blog

path_qs()

The URL including PATH_INFO and the query string.

E.g, /app/blog?id=10

raw_path()

The URL including raw PATH INFO without the host or scheme. Warning, the path is unquoted and may contains non valid URL characters

E.g., /my%2Fpath%7Cwith%21some%25strange%24characters

query()

A multidict with all the variables in the query string.

query_string()

The query string in the URL.

E.g., id=10

headers()

A case-insensitive multidict proxy with all headers.

raw_headers()

A sequence of pars for all headers.

_http_date()

Process a date string, return a datetime object

if_modified_since(_IF_MODIFIED_SINCE=None)

The value of If-Modified-Since HTTP header, or None.

This header is represented as a datetime object.

if_unmodified_since(_IF_UNMODIFIED_SINCE=None)

The value of If-Unmodified-Since HTTP header, or None.

This header is represented as a datetime object.

if_range(_IF_RANGE=None)

The value of If-Range HTTP header, or None.

This header is represented as a datetime object.

keep_alive()

Is keepalive enabled by client?

cookies()

Return request cookies.

A read-only dictionary-like object.

http_range()

The content of Range HTTP header.

Return a slice instance.

content()

Return raw payload stream.

has_body()

Return True if request’s HTTP BODY can be read, False otherwise.

can_read_body()

Return True if request’s HTTP BODY can be read, False otherwise.

body_exists()

Return True if request has HTTP BODY, False otherwise.

release()

Release request.

Eat unread part of HTTP BODY if present.

read()

Read request body if present.

Returns bytes object with full request content.

text()

Return BODY as text using encoding from .charset.

json()

Return BODY as JSON.

multipart()

Return async iterator to process BODY as multipart.

post()

Return POST parameters.

__repr__()
_prepare_hook(response)
class Request(*args, **kwargs)
__init__(*args, **kwargs)
__setattr__(name, val)
clone()
match_info()

Result of route resolving.

app()

Application instance.

config_dict()
_prepare_hook(response)