class documentation

class Request:

Known subclasses: werkzeug.wrappers.request.Request

View In Hierarchy

Represents the non-IO parts of a HTTP request, including the method, URL info, and headers.

This class is not meant for general use. It should only be used when implementing WSGI, ASGI, or another HTTP application spec. Werkzeug provides a WSGI implementation at :cls:`werkzeug.wrappers.Request`.

New in version 2.0.
Parameters
methodThe method the request was made with, such as GET.
schemeThe URL scheme of the protocol the request used, such as https or wss.
serverThe address of the server. (host, port), (path, None) for unix sockets, or None if not known.
root​_pathThe prefix that the application is mounted under. This is prepended to generated URLs, but is not part of route matching.
pathThe path part of the URL after root_path.
query​_stringThe part of the URL after the "?".
headersThe headers received with the request.
remote​_addrThe address of the client sending the request.
Method __init__ Undocumented
Method __repr__ Undocumented
Class Variable access​_control​_request​_headers Undocumented
Class Variable access​_control​_request​_method Undocumented
Class Variable charset Undocumented
Class Variable content​_encoding Undocumented
Class Variable content​_md5 Undocumented
Class Variable content​_type Undocumented
Class Variable date Undocumented
Class Variable encoding​_errors Undocumented
Class Variable max​_forwards Undocumented
Class Variable origin Undocumented
Class Variable referrer Undocumented
Class Variable trusted​_hosts Undocumented
Instance Variable headers Undocumented
Instance Variable method Undocumented
Instance Variable path Undocumented
Instance Variable query​_string Undocumented
Instance Variable remote​_addr Undocumented
Instance Variable root​_path Undocumented
Instance Variable scheme Undocumented
Instance Variable server Undocumented
Property accept​_charsets List of charsets this client supports as ~werkzeug.datastructures.CharsetAccept object.
Property accept​_encodings List of encodings this client accepts. Encodings in a HTTP term are compression encodings such as gzip. For charsets have a look at accept_charset.
Property accept​_languages List of languages this client accepts as ~werkzeug.datastructures.LanguageAccept object.
Property accept​_mimetypes List of mimetypes this client supports as ~werkzeug.datastructures.MIMEAccept object.
Property access​_route If a forwarded header exists this is a list of all ip addresses from the client ip to the last proxy server.
Property args The parsed URL parameters (the part in the URL after the question mark).
Property authorization The Authorization object in parsed form.
Property base​_url Like url but without the query string.
Property cache​_control A ~werkzeug.datastructures.RequestCacheControl object for the incoming cache control headers.
Property content​_length No summary
Property cookies A dict with the contents of all cookies transmitted with the request.
Property full​_path Requested path, including the query string.
Property host The host name the request was made to, including the port if it's non-standard. Validated with trusted_hosts.
Property host​_url The request URL scheme and host only.
Property if​_match An object containing all the etags in the If-Match header.
Property if​_modified​_since The parsed If-Modified-Since header as a datetime object.
Property if​_none​_match An object containing all the etags in the If-None-Match header.
Property if​_range The parsed If-Range header.
Property if​_unmodified​_since The parsed If-Unmodified-Since header as a datetime object.
Property is​_json Check if the mimetype indicates JSON data, either :mimetype:`application/json` or :mimetype:`application/*+json`.
Property is​_secure True if the request was made with a secure protocol (HTTPS or WSS).
Property mimetype No summary
Property mimetype​_params The mimetype parameters as dict. For example if the content type is text/html; charset=utf-8 the params would be {'charset': 'utf-8'}.
Property pragma No summary
Property range The parsed Range header.
Property root​_url The request URL scheme, host, and root path. This is the root that the application is accessed from.
Property url The full request URL with the scheme, host, root path, path, and query string.
Property url​_charset The charset that is assumed for URLs. Defaults to the value of charset.
Property user​_agent No summary
Method ​_parse​_content​_type Undocumented
Instance Variable ​_parsed​_content​_type Undocumented
def __init__(self, method, scheme, server, root_path, path, query_string, headers, remote_addr):

Undocumented

Parameters
method:strUndocumented
scheme:strUndocumented
server:t.Optional[t.Tuple[str, t.Optional[int]]]Undocumented
root​_path:strUndocumented
path:strUndocumented
query​_string:bytesUndocumented
headers:HeadersUndocumented
remote​_addr:t.Optional[str]Undocumented
def __repr__(self):

Undocumented

Returns
strUndocumented
access_control_request_headers =

Undocumented

access_control_request_method =

Undocumented

charset: str =

Undocumented

content_encoding =

Undocumented

content_md5 =

Undocumented

content_type =

Undocumented

date =

Undocumented

encoding_errors: str =

Undocumented

max_forwards =

Undocumented

origin =

Undocumented

referrer =

Undocumented

trusted_hosts: t.Optional[t.List[str]] =

Undocumented

headers =

Undocumented

method =

Undocumented

path =

Undocumented

query_string =

Undocumented

remote_addr =

Undocumented

root_path =

Undocumented

scheme =

Undocumented

server =

Undocumented

@cached_property
accept_charsets: CharsetAccept =
List of charsets this client supports as ~werkzeug.datastructures.CharsetAccept object.
@cached_property
accept_encodings: Accept =
List of encodings this client accepts. Encodings in a HTTP term are compression encodings such as gzip. For charsets have a look at accept_charset.
@cached_property
accept_languages: LanguageAccept =

List of languages this client accepts as ~werkzeug.datastructures.LanguageAccept object.

@cached_property
accept_mimetypes: MIMEAccept =
List of mimetypes this client supports as ~werkzeug.datastructures.MIMEAccept object.
@cached_property
access_route: t.List[str] =
If a forwarded header exists this is a list of all ip addresses from the client ip to the last proxy server.
@cached_property
args: MultiDict[str, str] =

The parsed URL parameters (the part in the URL after the question mark).

By default an ~werkzeug.datastructures.ImmutableMultiDict is returned from this function. This can be changed by setting parameter_storage_class to a different type. This might be necessary if the order of the form data is important.

@cached_property
authorization: t.Optional[Authorization] =
The Authorization object in parsed form.
@cached_property
base_url: str =
Like url but without the query string.
A ~werkzeug.datastructures.RequestCacheControl object for the incoming cache control headers.
@cached_property
content_length: t.Optional[int] =
The Content-Length entity-header field indicates the size of the entity-body in bytes or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET.
@cached_property
cookies: ImmutableMultiDict[str, str] =
A dict with the contents of all cookies transmitted with the request.
@cached_property
full_path: str =
Requested path, including the query string.
@cached_property
host: str =
The host name the request was made to, including the port if it's non-standard. Validated with trusted_hosts.
@cached_property
host_url: str =
The request URL scheme and host only.
@cached_property
if_match: ~werkzeug.datastructures.ETags =
An object containing all the etags in the If-Match header.
@cached_property
if_modified_since: t.Optional[datetime] =

The parsed If-Modified-Since header as a datetime object.

Changed in version 2.0: The datetime object is timezone-aware.
@cached_property
if_none_match: ~werkzeug.datastructures.ETags =
An object containing all the etags in the If-None-Match header.
@cached_property
if_range: IfRange =

The parsed If-Range header.

Changed in version 2.0: IfRange.date is timezone-aware.
New in version 0.7.
@cached_property
if_unmodified_since: t.Optional[datetime] =

The parsed If-Unmodified-Since header as a datetime object.

Changed in version 2.0: The datetime object is timezone-aware.
@property
is_json: bool =
Check if the mimetype indicates JSON data, either :mimetype:`application/json` or :mimetype:`application/*+json`.
@property
is_secure: bool =
True if the request was made with a secure protocol (HTTPS or WSS).
@property
mimetype: str =
Like content_type, but without parameters (eg, without charset, type etc.) and always lowercase. For example if the content type is text/HTML; charset=utf-8 the mimetype would be 'text/html'.
@property
mimetype_params: t.Dict[str, str] =
The mimetype parameters as dict. For example if the content type is text/html; charset=utf-8 the params would be {'charset': 'utf-8'}.
The Pragma general-header field is used to include implementation-specific directives that might apply to any recipient along the request/response chain. All pragma directives specify optional behavior from the viewpoint of the protocol; however, some systems MAY require that behavior be consistent with the directives.
@cached_property
range: ~werkzeug.datastructures.Range =

The parsed Range header.

New in version 0.7.
@cached_property
root_url: str =
The request URL scheme, host, and root path. This is the root that the application is accessed from.
@cached_property
url: str =
The full request URL with the scheme, host, root path, path, and query string.
@property
url_charset: str =

The charset that is assumed for URLs. Defaults to the value of charset.

New in version 0.6.
@cached_property
user_agent: UserAgent =

The user agent. Use user_agent.string to get the header value. Set user_agent_class to a subclass of ~werkzeug.user_agent.UserAgent to provide parsing for the other properties or other extended data.

Changed in version 2.0: The built in parser is deprecated and will be removed in Werkzeug 2.1. A UserAgent subclass must be set to parse data from the string.
def _parse_content_type(self):

Undocumented

_parsed_content_type =

Undocumented