Package AccessGrid :: Module DataStore :: Class HTTPTransferHandler
[show private | hide private]
[frames | no frames]

Class HTTPTransferHandler

BaseRequestHandler --+        
                     |        
  StreamRequestHandler --+    
                         |    
    BaseHTTPRequestHandler --+
                             |
                            HTTPTransferHandler


Method Summary
  do_GET(self)
  do_POST(self)
  log_message(self, format, *args)
Log an arbitrary message.
  ProcessFileUpload(self, identityToken, prefix, transfer_key, file_num)
Process a possible file upload.
  ProcessGet(self, identityToken)
Handle an HTTP GET.
  ProcessManifest(self, prefix, identityToken)
Read the manifest from the input.
    Inherited from BaseHTTPRequestHandler
  address_string(self)
Return the client address formatted for logging.
  date_time_string(self)
Return the current date and time formatted for a message header.
  end_headers(self)
Send the blank line ending the MIME headers.
  handle(self)
Handle multiple requests if necessary.
  handle_one_request(self)
Handle a single HTTP request.
  log_date_time_string(self)
Return the current time formatted for logging.
  log_error(self, *args)
Log an error.
  log_request(self, code, size)
Log an accepted request.
  parse_request(self)
Parse a request (internal).
  send_error(self, code, message)
Send and log an error reply.
  send_header(self, keyword, value)
Send a MIME header.
  send_response(self, code, message)
Send the response header and log the response code.
  version_string(self)
Return the server software version string.
    Inherited from StreamRequestHandler
  finish(self)
  setup(self)
    Inherited from BaseRequestHandler
  __init__(self, request, client_address, server)

Class Variable Summary
    Inherited from BaseHTTPRequestHandler
str error_message_format = '<head>\n<title>Error response</t...
list monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'J...
str protocol_version = 'HTTP/1.0'
dict responses = {400: ('Bad request', 'Bad request syntax or...
str server_version = 'BaseHTTP/0.3'
str sys_version = 'Python/2.3.5'
list weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',...
    Inherited from StreamRequestHandler
int rbufsize = -1                                                                    
int wbufsize = 0                                                                     

Method Details

log_message(self, format, *args)

Log an arbitrary message.

This is used by all other logging functions. Override it if you have specific logging wishes.

The first argument, FORMAT, is a format string for the message to be logged. If the format string contains any % escapes requiring parameters, they should be specified as subsequent arguments (it's just like printf!).

The client host and current date/time are prefixed to every message.
Overrides:
BaseHTTPServer.BaseHTTPRequestHandler.log_message (inherited documentation)

ProcessFileUpload(self, identityToken, prefix, transfer_key, file_num)

Process a possible file upload.

Look up the prefix to get the handler for that prefix.

Look up the transfer key in the server to get the manifest.

Look in the manifest for the metadata about the file.

Do some preliminary checks (see if the Content-Length matches the size in the manifest, etc).

Create a local file in the right location for the download.

Copy the data from the socket into the file location, collecting a md5 checksum along the way.

Verify the checksum, and nuke the file if it's wrong.

ProcessGet(self, identityToken)

Handle an HTTP GET.

Extract the name of the file from the path; the path should be of the format /<prefix>/<filename>. Any other path is incorrect and will cause a FileNotFound exception to be raised.

Call the datastore's OpenFile method to open the file and return a python file handle to it. This method can return FileNotFound and NotAuthorized exceptions; return an appropriate error code for each.

ProcessManifest(self, prefix, identityToken)

Read the manifest from the input.

We can't just let the ConfigParser read as it will read until EOF, and the server is leaving the socket open so it can write the transfer key back. So we need to obey the Content-Length header, reading that many bytes, stuff them into a StringIO, and pass that to the ConfigParser to parse.

Generated by Epydoc 2.1 on Thu Apr 14 16:39:31 2005 http://epydoc.sf.net