wsgiref.util.guess_scheme()

wsgiref.util.guess_scheme(environ) Return a guess for whether wsgi.url_scheme should be “http” or “https”, by checking for a HTTPS environment variable in the environ dictionary. The return value is a string. This function is useful when creating a gateway that wraps CGI or a CGI-like protocol such as FastCGI. Typically, servers providing such protocols will include a HTTPS variable with a value of “1” “yes”, or “on” when a request is received via SSL. So, this function returns “https” if su

wsgiref.util.is_hop_by_hop()

wsgiref.util.is_hop_by_hop(header_name) Return true if ‘header_name’ is an HTTP/1.1 “Hop-by-Hop” header, as defined by RFC 2616.

wsgiref.util.shift_path_info()

wsgiref.util.shift_path_info(environ) Shift a single name from PATH_INFO to SCRIPT_NAME and return the name. The environ dictionary is modified in-place; use a copy if you need to keep the original PATH_INFO or SCRIPT_NAME intact. If there are no remaining path segments in PATH_INFO, None is returned. Typically, this routine is used to process each portion of a request URI path, for example to treat the path as a series of dictionary keys. This routine modifies the passed-in environment to m

wsgiref.util.FileWrapper

class wsgiref.util.FileWrapper(filelike, blksize=8192) A wrapper to convert a file-like object to an iterator. The resulting objects support both __getitem__() and __iter__() iteration styles, for compatibility with Python 2.1 and Jython. As the object is iterated over, the optional blksize parameter will be repeatedly passed to the filelike object’s read() method to obtain bytestrings to yield. When read() returns an empty bytestring, iteration is ended and is not resumable. If filelike has

wsgiref.util.application_uri()

wsgiref.util.application_uri(environ) Similar to request_uri(), except that the PATH_INFO and QUERY_STRING variables are ignored. The result is the base URI of the application object addressed by the request.

wsgiref.simple_server.WSGIServer

class wsgiref.simple_server.WSGIServer(server_address, RequestHandlerClass) Create a WSGIServer instance. server_address should be a (host,port) tuple, and RequestHandlerClass should be the subclass of http.server.BaseHTTPRequestHandler that will be used to process requests. You do not normally need to call this constructor, as the make_server() function can handle all the details for you. WSGIServer is a subclass of http.server.HTTPServer, so all of its methods (such as serve_forever() and

wsgiref.simple_server.WSGIRequestHandler.handle()

handle() Process the HTTP request. The default implementation creates a handler instance using a wsgiref.handlers class to implement the actual WSGI application interface.

wsgiref.simple_server.WSGIServer.set_app()

set_app(application) Sets the callable application as the WSGI application that will receive requests.

wsgiref.simple_server.WSGIServer.get_app()

get_app() Returns the currently-set application callable.

wsgiref.simple_server.WSGIRequestHandler.get_environ()

get_environ() Returns a dictionary containing the WSGI environment for a request. The default implementation copies the contents of the WSGIServer object’s base_environ dictionary attribute and then adds various headers derived from the HTTP request. Each call to this method should return a new dictionary containing all of the relevant CGI environment variables as specified in PEP 3333.