alexapy.aiohttp.web_request
¶
Classes¶
BaseRequest
: Abstract base class for generic types.FileField
: Undocumented.Request
: Abstract base class for generic types.
- class alexapy.aiohttp.web_request.BaseRequest(message: alexapy.aiohttp.http_parser.RawRequestMessage, payload: alexapy.aiohttp.streams.StreamReader, protocol: RequestHandler, payload_writer: alexapy.aiohttp.abc.AbstractStreamWriter, task: asyncio.Task[None], loop: asyncio.events.AbstractEventLoop, *, client_max_size: int = 1048576, state: Optional[Dict[str, Any]] = None, scheme: Optional[str] = None, host: Optional[str] = None, remote: Optional[str] = None)¶
Inheritance
- body_exists¶
Return True if request has HTTP BODY, False otherwise.
- property can_read_body: bool¶
Return True if request’s HTTP BODY can be read, False otherwise.
- clone(*, method: str = <object object>, rel_url: typing.Union[str, yarl.URL] = <object object>, headers: typing.Union[typing.Mapping[typing.Union[str, multidict._multidict.istr], str], multidict._multidict.CIMultiDict, multidict._multidict.CIMultiDictProxy] = <object object>, scheme: str = <object object>, host: str = <object object>, remote: str = <object object>) alexapy.aiohttp.web_request.BaseRequest ¶
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.
- content¶
Return raw payload stream.
- cookies¶
Return request cookies.
A read-only dictionary-like object.
- 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
- get_extra_info(name: str, default: Optional[Any] = None) Any ¶
Extra info from protocol transport
- property has_body: bool¶
Return True if request’s HTTP BODY can be read, False otherwise.
- headers¶
A case-insensitive multidict proxy with all headers.
- 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
- http_range¶
The content of Range HTTP header.
Return a slice instance.
- if_match¶
The value of If-Match HTTP header, or None.
This header is represented as a tuple of ETag objects.
- if_modified_since¶
The value of If-Modified-Since HTTP header, or None.
This header is represented as a datetime object.
- if_none_match¶
The value of If-None-Match HTTP header, or None.
This header is represented as a tuple of ETag objects.
- if_range¶
The value of If-Range HTTP header, or None.
This header is represented as a datetime object.
- if_unmodified_since¶
The value of If-Unmodified-Since HTTP header, or None.
This header is represented as a datetime object.
- async json(*, loads: typing.Callable[[str], typing.Any] = <function loads>) Any ¶
Return BODY as JSON.
- keep_alive¶
Is keepalive enabled by client?
- method¶
Read only property for getting HTTP method.
The value is upper-cased str like ‘GET’, ‘POST’, ‘PUT’ etc.
- async multipart() alexapy.aiohttp.multipart.MultipartReader ¶
Return async iterator to process BODY as multipart.
- 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
- async post() multidict._multidict.MultiDictProxy ¶
Return POST parameters.
- query¶
A multidict with all the variables in the query string.
- query_string¶
The query string in the URL.
E.g., id=10
- raw_headers¶
A sequence of pairs for all headers.
- 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
- async read() bytes ¶
Read request body if present.
Returns bytes object with full request content.
- async release() None ¶
Release request.
Eat unread part of HTTP BODY if present.
- 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
- 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’.
- secure¶
A bool indicating if the request is handled with SSL.
- async text() str ¶
Return BODY as text using encoding from .charset.
- version¶
Read only property for getting HTTP version of request.
Returns aiohttp.protocol.HttpVersion instance.
- class alexapy.aiohttp.web_request.FileField(name: str, filename: str, file: _io.BufferedReader, content_type: str, headers: multidict._multidict.CIMultiDictProxy)¶
Inheritance
- class alexapy.aiohttp.web_request.Request(*args: Any, **kwargs: Any)¶
Inheritance
- property app: Application¶
Application instance.
- clone(*, method: str = <object object>, rel_url: typing.Union[str, yarl.URL] = <object object>, headers: typing.Union[typing.Mapping[typing.Union[str, multidict._multidict.istr], str], multidict._multidict.CIMultiDict, multidict._multidict.CIMultiDictProxy] = <object object>, scheme: str = <object object>, host: str = <object object>, remote: str = <object object>) alexapy.aiohttp.web_request.Request ¶
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.
- match_info¶
Result of route resolving.