Request

Request object.

Interface

class wptserve.request.Authentication(headers)[source]

Object for dealing with HTTP Authentication

username

The username supplied in the HTTP Authorization header, or None

password

The password supplied in the HTTP Authorization header, or None

class wptserve.request.CookieValue(morsel)[source]

Representation of cookies.

Note that cookies are considered read-only and the string value of the cookie will not change if you update the field values. However this is not enforced.

key

The name of the cookie.

value

The value of the cookie

expires

The expiry date of the cookie

path

The path of the cookie

comment

The comment of the cookie.

domain

The domain with which the cookie is associated

max_age

The max-age value of the cookie.

secure

Whether the cookie is marked as secure

httponly

Whether the cookie is marked as httponly

class wptserve.request.Cookies[source]

MultiDict specialised for Cookie values

class wptserve.request.MultiDict[source]

Dictionary type that holds multiple values for each key

first(key, default=<object object>)[source]

Get the first value with a given key

Parameters:
  • key – The key to lookup
  • default – The default to return if key is not found (throws if nothing is specified)
get_list(key)[source]

Get all values with a given key as a list

Parameters:key – The key to lookup
last(key, default=<object object>)[source]

Get the last value with a given key

Parameters:
  • key – The key to lookup
  • default – The default to return if key is not found (throws if nothing is specified)
class wptserve.request.Request(request_handler)[source]

Object representing a HTTP request.

doc_root

The local directory to use as a base when resolving paths

route_match

Regexp match object from matching the request path to the route selected for the request.

protocol_version

HTTP version specified in the request.

method

HTTP method in the request.

request_path

Request path as it appears in the HTTP request.

url_base

The prefix part of the path; typically / unless the handler has a url_base set

url

Absolute URL for the request.

url_parts

Parts of the requested URL as obtained by urlparse.urlsplit(path)

request_line

Raw request line

headers

RequestHeaders object providing a dictionary-like representation of the request headers.

raw_headers.

Dictionary of non-normalized request headers.

body

Request body as a string

raw_input

File-like object representing the body of the request.

GET

MultiDict representing the parameters supplied with the request. Note that these may be present on non-GET requests; the name is chosen to be familiar to users of other systems such as PHP.

POST

MultiDict representing the request body parameters. Most parameters are present as string values, but file uploads have file-like values.

cookies

Cookies object representing cookies sent with the request with a dictionary-like interface.

auth

Object with username and password properties representing any credentials supplied using HTTP authentication.

server

Server object containing information about the server environment.

class wptserve.request.RequestHeaders(items)[source]

Dictionary-like API for accessing request headers.

get(key, default=None)[source]

Get a string representing all headers with a particular value, with multiple headers separated by a comma. If no header is found return a default value

Parameters:
  • key – The header name to look up (case-insensitive)
  • default – The value to return in the case of no match
get_list(key, default=<object object>)[source]

Get all the header values for a particular field name as a list

class wptserve.request.Server(request)[source]

Data about the server environment

config

Environment configuration information with information about the various servers running, their hostnames and ports.

stash

Stash object holding state stored on the server between requests.