Request


Attributes

a content_length

<Converted <Proxy for WSGI environ 'CONTENT_LENGTH' key> int>

a script_name

<Proxy for WSGI environ 'SCRIPT_NAME' key>

a application_url

The URL including SCRIPT_NAME (no PATH_INFO or query string)

a server_name

<Proxy for WSGI environ 'SERVER_NAME' key>

a accept_charset

<Converted <Proxy for WSGI environ 'HTTP_ACCEPT_CHARSET' key> accept header>

a accept_encoding

<Converted <Proxy for WSGI environ 'HTTP_ACCEPT_ENCODING' key> accept header>

a str_postvars

<Deprecated attribute str_postvars: <property object at 0x87bf48c>>

a referrer

<Proxy for WSGI environ 'HTTP_REFERER' key>

a cookies

Like .str_cookies, but may decode values and keys

a path_qs

The path of the request, without host but with query string

a str_POST

Return a MultiDict containing all the variables from a POST form request. Does not return anything for non-POST requests or for non-form requests (returns empty dict-like object in that case).

a if_range

<Converted <Proxy for WSGI environ 'HTTP_IF_RANGE' key> IfRange object>

a unicode_errors

'strict'

a GET

Like .str_GET, but may decode values and keys

a postvars

<Deprecated attribute postvars: <property object at 0x87bfa7c>>

a server_port

<Converted <Proxy for WSGI environ 'SERVER_PORT' key> int>

a method

<Proxy for WSGI environ 'REQUEST_METHOD' key>

a body

Return the content of the request body.

a if_none_match

<Converted <Proxy for WSGI environ 'HTTP_IF_NONE_MATCH' key> ETag>

a str_cookies

Return a plain dictionary of cookies as found in the request.

a host

Host name provided in HTTP_HOST, with fall-back to SERVER_NAME

a host_url

The URL through the host (no path)

a path

The path of the request, without host or query string

a POST

Like .str_POST, but may decode values and keys

a body_file

Access the body of the request (wsgi.input) as a file-like object.

If you set this value, CONTENT_LENGTH will also be updated (either set to -1, 0 if you delete the attribute, or if you set the attribute to a string then the length of the string).

a range

<Converted <Proxy for WSGI environ 'HTTP_RANGE' key> Range object>

a content_type

<Proxy for WSGI environ 'CONTENT_TYPE' key>

a user_agent

<Proxy for WSGI environ 'HTTP_USER_AGENT' key>

a query_string

<Proxy for WSGI environ 'QUERY_STRING' key>

a is_xhr

Returns a boolean if X-Requested-With is present and XMLHttpRequest

Note: this isn't set by every XMLHttpRequest request, it is only set if you are using a Javascript library that sets it (or you set the header yourself manually). Currently Prototype and jQuery are known to set this header.

a path_url

The URL including SCRIPT_NAME and PATH_INFO, but not QUERY_STRING

a params

Like .str_params, but may decode values and keys

a scheme

<Proxy for WSGI environ 'wsgi.url_scheme' key>

a cache_control

Get/set/modify the Cache-Control header (section 14.9)

a str_queryvars

<Deprecated attribute str_queryvars: <property object at 0x87bf9dc>>

a urlvars

Return any named variables matched in the URL.

Takes values from environ['wsgiorg.routing_args']. Systems like routes set this value.

a referer

<Proxy for WSGI environ 'HTTP_REFERER' key>

a pragma

<Proxy for WSGI environ 'HTTP_PRAGMA' key>

a if_match

<Converted <Proxy for WSGI environ 'HTTP_IF_MATCH' key> ETag>

a headers

All the request headers as a case-insensitive dictionary-like object.

a if_unmodified_since

<Converted <Proxy for WSGI environ 'HTTP_IF_UNMODIFIED_SINCE' key> HTTP date>

a urlargs

Return any positional variables matched in the URL.

Takes values from environ['wsgiorg.routing_args']. Systems like routes set this value.

a decode_param_names

False

a accept

<Converted <Proxy for WSGI environ 'HTTP_ACCEPT' key> MIME Accept>

a remote_user

<Proxy for WSGI environ 'REMOTE_USER' key>

a request_body_tempfile_limit

10240

a remote_addr

<Proxy for WSGI environ 'REMOTE_ADDR' key>

a charset

None

a str_params

A dictionary-like object containing both the parameters from the query string and request body.

a path_info

<Proxy for WSGI environ 'PATH_INFO' key>

a accept_language

<Converted <Proxy for WSGI environ 'HTTP_ACCEPT_LANGUAGE' key> accept header>

a max_forwards

<Converted <Proxy for WSGI environ 'HTTP_MAX_FORWARDS' key> int>

a date

<Converted <Proxy for WSGI environ 'HTTP_DATE' key> HTTP date>

a queryvars

<Deprecated attribute queryvars: <property object at 0x87bf98c>>

a str_GET

Return a MultiDict containing all the variables from the QUERY_STRING.

a url

The full request URL, including QUERY_STRING

a if_modified_since

<Converted <Proxy for WSGI environ 'HTTP_IF_MODIFIED_SINCE' key> HTTP date>

a environ

The WSGI environment dictionary for this request

Methods

f __init__(self, environ=None, environ_getter=None, charset=(No Default), unicode_errors=(No Default), decode_param_names=(No Default)) ...

f relative_url(self, other_url, to_application=False) ...

Resolve other_url relative to the request URL.

If to_application is True, then resolve it relative to the URL with only SCRIPT_NAME

f path_info_pop(self) ...

'Pops' off the next segment of PATH_INFO, pushing it onto SCRIPT_NAME, and returning the popped segment. Returns None if there is nothing left on PATH_INFO.

Does not return '' when there's an empty segment (like /path//path); these segments are just ignored.

f path_info_peek(self) ...

Returns the next segment on PATH_INFO, or None if there is no next segment. Doesn't modify the environment.

f copy(self) ...

Copy the request and environment object.

This only does a shallow copy, except of wsgi.input

f copy_get(self) ...

Copies the request and environment object, but turning this request into a GET along the way. If this was a POST request (or any other verb) then it becomes GET, and the request body is thrown away.

f remove_conditional_headers(self, remove_encoding=True) ...

Remove headers that make the request conditional.

These headers can cause the response to be 304 Not Modified, which in some cases you may not want to be possible.

This does not remove headers like If-Match, which are used for conflict detection.

f call_application(self, application, catch_exc_info=False) ...

Call the given WSGI application, returning (status_string, headerlist, app_iter)

Be sure to call app_iter.close() if it's there.

If catch_exc_info is true, then returns (status_string, headerlist, app_iter, exc_info), where the fourth item may be None, but won't be if there was an exception. If you don't do this and there was an exception, the exception will be raised directly.

f get_response(self, application, catch_exc_info=False) ...

Like .call_application(application), except returns a response object with .status, .headers, and .body attributes.

This will use self.ResponseClass to figure out the class of the response object to return.

f blank(cls, path, environ=None, base_url=None, headers=None, **kw) ...

Create a blank request environ (and Request wrapper) with the given path (path should be urlencoded), and any keys from environ.

The path will become path_info, with any query string split off and used.

All necessary keys will be added to the environ, but the values you pass in will take precedence. If you pass in base_url then wsgi.url_scheme, HTTP_HOST, and SCRIPT_NAME will be filled in from that value.

Any extra keyword will be passed to __init__ (e.g., decode_param_names).

See the source for more information.