Connection object which will represent the connection between the server and client and is used to disconnect the socket when a timeout event occurs.
Separated thread used to disconnect and clean up (in)active, long running connections. The connection timeout limit is set to 13 seconds. If a connection exceeds this limit, an HTTP response with status “406 Gateway timeout” is sent and the connection is closed.
Request handler
On each connection closed, the measured phase statistics are flushed to the statistics log file.
Parse an HTTP request blob and return a slightly modified http.client.HTTPMessage instance containing WSGI’s environment values.
>>> request = """GET /kv55/57330430 HTTP/1.1
... Host: cache.govi.openov.nl
... User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0) Firefox/4.0
... Accept: text/html,application/xml;q=0.9,*/*;q=0.8
... Accept-Language: en-us,en;q=0.5
... Accept-Encoding: gzip, deflate
... Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
... Keep-Alive: 115
... DNT: 1
... Connection: keep-alive
... Cache-Control: max-age=0
...
... """
>>> env = RequestHandler(object(), None).parse_request(request)
>>> for e in env.items():
... print e
('accept-language', 'en-us,en;q=0.5')
('accept-encoding', 'gzip, deflate')
('dnt', '1')
('connection', 'keep-alive')
('keep-alive', '115')
('accept', 'text/html,application/xml;q=0.9,*/*;q=0.8')
('user-agent', 'Mozilla/5.0 (X11; Linux i686; rv:2.0) Firefox/4.0')
('accept-charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7')
('host', 'cache.govi.openov.nl')
('request_method', 'GET')
('http_host', 'cache.govi.openov.nl')
('path_info', '/kv55/57330430')
('cache-control', 'max-age=0')
Given the WGSI environment, process the environment values, initialise the target module/class and dispatch the request based on the HTTP request method (GET/POST/HEAD).
Wrapper class used to connect functionality of RequestHandler to the requested URL module. For example, send_response() is used for sending the HTTP response (headers, status and content) to the client.
Send HTTP response (consisting of headers, status and HTTP response body) to the client. This function is a wrapper of request_handler.RequestHandler.send_response().