Package DebTorrent :: Module HTTPHandler :: Class HTTPRequest
[hide private]
[frames] | no frames]

Class HTTPRequest

source code

A single request on an HTTP connection.

Handles one of possibly many HTTP GET or HEAD requests from a client using HTTP/1.1.

Instance Methods [hide private]
 
__init__(self, header, command, path, encoding, headers)
Initialize the instance.
source code
 
save_answer(self, r)
Save an answer, replacing the old one if it's better.
source code
boolean
has_answer(self)
Determine whether an answer is available for the request.
source code
(int, string, dictionary, string)
get_answer(self)
Get the saved answer.
source code
Instance Variables [hide private]
(int, string, dictionary, string) answer
the HTTP status code, status message, headers, and package data, or None if the answer is not yet available
string command
the requested command ('GET' or 'HEAD')
string encoding
the encoding to use when sending the response
string header
the first header line received from the request
dictionary headers
the headers received with the request
string path
the requested path to get
Method Details [hide private]

__init__(self, header, command, path, encoding, headers)
(Constructor)

source code 
Initialize the instance.
Parameters:
  • header (string) - the first header line received from the request
  • command (string) - the requested command ('GET' or 'HEAD')
  • path (string) - the requested path to get
  • encoding (string) - the encoding to use when sending the response
  • headers (dictionary) - the headers received with the request

save_answer(self, r)

source code 
Save an answer, replacing the old one if it's better.
Parameters:
  • r ((int, string, dictionary, string)) - the HTTP status code, status message, headers, and package data

has_answer(self)

source code 
Determine whether an answer is available for the request.
Returns: boolean
whether the answer is available yet

get_answer(self)

source code 
Get the saved answer.
Returns: (int, string, dictionary, string)
the HTTP status code, status message, headers, and package data, or None if the answer is not yet available