A wrapper for WSGI environment dictionaries that adds a lot of convenient access methods and properties. Most of them are read-only.
Adding new attributes to a request actually adds them to the environ dictionary (as 'bottle.request.ext.<name>'). This is the recommended way to store and access request-specific data.
Method | copy |
Return a new Request with a shallow environ copy. |
Method | get_cookie |
No summary |
Method | get_header |
Return the value of a request header, or a given default value. |
Method | path_shift |
Shift path segments from path to script_name and vice versa. |
Constant | MEMFILE_MAX |
Undocumented |
Instance Variable | environ |
Undocumented |
Method | __delitem__ |
Undocumented |
Method | __getattr__ |
Search in self.environ for additional user defined attributes. |
Method | __getitem__ |
Undocumented |
Method | __init__ |
Wrap a WSGI environ dictionary. |
Method | __iter__ |
Undocumented |
Method | __len__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __setattr__ |
Undocumented |
Method | __setitem__ |
Change an environ value and clear all caches that depend on it. |
Method | _get_body_string |
read body until content-length or MEMFILE_MAX into a string. Raise HTTPError(413) on requests that are to large. |
Method | _iter_body |
Undocumented |
Method | _iter_chunked |
Undocumented |
Method | get |
Undocumented |
Method | keys |
Undocumented |
Class Variable | __slots__ |
Undocumented |
Property | _body |
Undocumented |
Property | app |
Bottle application handling this request. |
Property | auth |
No summary |
Property | body |
No summary |
Property | chunked |
True if Chunked transfer encoding was. |
Property | content_length |
The request body length as an integer. The client is responsible to set this header. Otherwise, the real length of the body is unknown and -1 is returned. In this case, body will be empty. |
Property | content_type |
The Content-Type header as a lowercase-string (default: empty). |
Property | cookies |
Cookies parsed into a FormsDict . Signed cookies are NOT decoded. Use get_cookie if you expect signed cookies. |
Property | files |
File uploads parsed from multipart/form-data encoded POST or PUT request body. The values are instances of FileUpload . |
Property | forms |
No summary |
Property | fullpath |
Request path including script_name (if present). |
Property | headers |
A WSGIHeaderDict that provides case-insensitive access to HTTP request headers. |
Property | is_ajax |
Alias for is_xhr . "Ajax" is not the right term. |
Property | is_xhr |
True if the request was triggered by a XMLHttpRequest. This only works with JavaScript libraries that support the X-Requested-With header (most of the popular libraries do). |
Property | json |
No summary |
Property | method |
The REQUEST_METHOD value as an uppercase string. |
Property | params |
A FormsDict with the combined values of query and forms . File uploads are stored in files . |
Property | path |
The value of PATH_INFO with exactly one prefixed slash (to fix broken clients and avoid the "empty path" edge case). |
Property | POST |
The values of forms and files combined into a single FormsDict . Values are either strings (form values) or instances of cgi.FieldStorage (file uploads). |
Property | query |
No summary |
Property | query_string |
The raw query part of the URL (everything in between ? and #) as a string. |
Property | remote_addr |
The client IP as a string. Note that this information can be forged by malicious clients. |
Property | remote_route |
No summary |
Property | route |
The bottle Route object that matches this request. |
Property | script_name |
No summary |
Property | url |
No summary |
Property | url_args |
The arguments extracted from the URL. |
Property | urlparts |
No summary |
Signed Cookie
, the
secret
must match the one used to create the cookie (see
BaseResponse.set_cookie
). If anything goes wrong (missing
cookie or wrong signature), return a default value.path
to script_name
andParameters | |
shift | The number of path segments to shift. May be negative to change the shift direction. (default: 1) |
MEMFILE_MAX
, this is either a temporary file or a
io.BytesIO
instance. Accessing this property for the first
time reads and replaces the wsgi.input environ variable.
Subsequent accesses just do a seek(0)
on the file object.body
will be empty.FormsDict
. Signed cookies are NOT
decoded. Use get_cookie
if you expect signed cookies.multipart/form-data
encoded POST or PUT
request body. The values are instances of FileUpload
.X-Requested-With
header (most of the popular libraries do).MEMFILE_MAX
are processed to avoid memory
exhaustion.query_string
parsed into a FormsDict
. These
values are sometimes called "URL arguments" or "GET parameters", but
not to be confused with "URL wildcards" as they are provided by the
Router
.path
that was removed by a higher
level (server or routing middleware) before the application was
called. This script path is returned with leading and tailing
slashes.url
string as an urlparse.SplitResult
tuple.
The tuple contains (scheme, host, path, query_string and fragment),
but the fragment is always empty because it is not visible to the
server.