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

Class HTTPHandler

source code

The handler for all new and existing HTTP connections.

Supports HTTP/1.1 persistent connections with pipelining if the protocol is set to 'HTTP/1.1'.

Instance Methods [hide private]
 
__init__(self, getfunc, minflush, logfile=None, hupmonitor=None, protocol='HTTP/1.0')
Initialize the instance.
source code
 
external_connection_made(self, connection)
Create a new HTTPConnection object.
source code
 
connection_flushed(self, connection)
Flush a connection.
source code
 
connection_lost(self, connection)
Remove the lost connection from the existing ones.
source code
 
data_came_in(self, connection, data)
Process incoming data on an existing connection.
source code
 
write_log(self, ip, ident, username, header, responsecode, length, referrer, useragent)
Print a log message.
source code
Instance Variables [hide private]
dictionary connections
all the existing connections, keys are the connection objects, values are the HTTPConnection objects
method getfunc
the method to call with the processed GET requests
float lastflush
the time of the last log flush
file log
the file to write the logs to
string logfile
the file name to write the logs to
float minflush
the minimum amount of time between flushing the log
string protocol
the HTTP protocol version to use
Method Details [hide private]

__init__(self, getfunc, minflush, logfile=None, hupmonitor=None, protocol='HTTP/1.0')
(Constructor)

source code 
Initialize the instance.
Parameters:
  • getfunc (method) - the method to call with the processed GET requests
  • minflush (float) - the minimum amount of time between flushing the log
  • logfile (string) - the file to write the logs to (optional, defaults to standard output)
  • hupmonitor (boolean) - whether to reopen the log file on a HUP signal (optional, default is False)
  • protocol (string) - the HTTP protocol version to use (optional, defaults to HTTP/1.0)

external_connection_made(self, connection)

source code 
Create a new HTTPConnection object.
Parameters:

connection_flushed(self, connection)

source code 
Flush a connection.
Parameters:

connection_lost(self, connection)

source code 
Remove the lost connection from the existing ones.
Parameters:

data_came_in(self, connection, data)

source code 
Process incoming data on an existing connection.
Parameters:

write_log(self, ip, ident, username, header, responsecode, length, referrer, useragent)

source code 
Print a log message.
Parameters:
  • ip (string) - the IP address of the connection
  • ident (string) - the type of connection
  • username (string) - the username from the client
  • header (string) - the first header line of the request
  • responsecode (int) - the HTTP status code of the response
  • length (int) - the number of bytes in the data returned
  • referrer (string) - the referer for the incoming request
  • useragent (string) - the client's useragent used to make the request