Package viewer :: Package lib :: Module asynchttp :: Class AsyncHTTPConnection
[hide private]
[frames] | no frames]

Class AsyncHTTPConnection

source code


Nested Classes [hide private]
  response_class
This class attempts to mimic HTTPResponse from httplib.
Instance Methods [hide private]
 
__init__(self, host=None, port=None) source code
 
_set_hostport(self, host, port) source code
 
set_debuglevel(self, level) source code
 
connect(self)
Connect to the host and port specified in __init__.
source code
 
close(self)
Close the connection to the HTTP server.
source code
 
send_entity(self, str)
Send `str' to the server.
source code
 
putrequest(self, method, url)
Send a request to the server.
source code
 
putheader(self, header, value)
Send a request header line to the server.
source code
 
endheaders(self)
Indicate that the last header line has been sent to the server.
source code
 
request(self, method, url, body=None, headers={})
Send a complete request to the server.
source code
 
_send_request(self, method, url, body, headers) source code
 
getresponse(self)
Get the response from the server.
source code
 
handle_connect(self)
Notification from asyncore that we are connected
source code
 
handle_close(self)
Notification from asyncore that the server has closed its end of the connection.
source code
 
handle_read(self) source code
 
handle_error(self)
Overload asyncore's exception handling
source code
 
collect_incoming_data(self, data)
asynchat calls this with data as it comes in
source code
 
_no_action(self)
overload asynchat.found_terminator This function will only be called when someone is badly confused
source code
 
_header_data(self)
overload asynchat.found_terminator for _STATE_ACCEPTING_HEADERS We assume that we have hit the blank line terminator after the HTTP response headers.
source code
 
_body_data(self)
overload asynchat.found_terminator for _STATE_REQUESTING_BODY We assume that we have the full body text
source code
 
_get_chunk_size(self)
Assume that chunkbuffer contains some text, begining with a line containing the chunk size in hex.
source code
 
_chunk_start_data(self)
overload asynchat.found_terminator for...
source code
 
_chunk_body_data(self)
overload asynchat.found_terminator for _STATE_CHUNK_BODY
source code
 
_chunk_residue_data(self)
overload asynchat.found_terminator for _STATE_CHUNK_RESIDUE
source code
 
handle_response(self)
This is an abstract function, the user MUST overload it
source code
 
__set_state(self, next_state)
Change state be setting _found_terminator
source code

Inherited from asynchat.async_chat: close_when_done, discard_buffers, found_terminator, get_terminator, handle_write, initiate_send, push, push_with_producer, readable, set_terminator, writable

Inherited from asynchat.async_chat (private): _collect_incoming_data, _get_data

Inherited from asyncore.dispatcher: __getattr__, __repr__, __str__, accept, add_channel, bind, create_socket, del_channel, handle_accept, handle_connect_event, handle_expt, handle_expt_event, handle_read_event, handle_write_event, listen, log, log_info, recv, send, set_reuse_addr, set_socket

Class Variables [hide private]
  _http_vsn = 11
  _http_vsn_str = 'HTTP/1.1'
  default_port = 80
  auto_open = 1
  debuglevel = 0

Inherited from asynchat.async_chat: ac_in_buffer_size, ac_out_buffer_size

Inherited from asyncore.dispatcher: accepting, addr, closing, connected, debug, ignore_log_types

Method Details [hide private]

__init__(self, host=None, port=None)
(Constructor)

source code 
Overrides: asyncore.dispatcher.__init__

connect(self)

source code 

Connect to the host and port specified in __init__. Add ourselves to thhe asyncore polling group

Overrides: asyncore.dispatcher.connect

close(self)

source code 

Close the connection to the HTTP server. And remove ourselves from the asyncore polling group

Overrides: asyncore.dispatcher.close

send_entity(self, str)

source code 

Send `str' to the server. Actually, we just append str to the block of text to be sent to the server when getresponse is called.

Note: the name was changed from httplib's 'HTTPConnection.send()' because it conflicts with asynchat

putrequest(self, method, url)

source code 

Send a request to the server.

`method' specifies an HTTP request method, e.g. 'GET'. `url' specifies the object being requested, e.g. '/index.html'.

This function actually only starts accumulating the request: nothing gets sent to the server until getresponse() is called.

putheader(self, header, value)

source code 

Send a request header line to the server.

For example: h.putheader('Accept', 'text/html') We don't actually send the header here, we stick it in a dictionary, to be sent when getresponse() is called. If you call putheader() with a duplicate key, it will wipe out the existing entry.

endheaders(self)

source code 

Indicate that the last header line has been sent to the server. Actually, we just copy the header dictionary into the request stream to be sent when getresponse() is called.

getresponse(self)

source code 

Get the response from the server. This actually starts the process of sending the request to the server. The response will be delivered in handle_response

handle_connect(self)

source code 

Notification from asyncore that we are connected

Overrides: asyncore.dispatcher.handle_connect

handle_close(self)

source code 

Notification from asyncore that the server has closed its end of the connection. If auto_open is TRUE, we will attempt to reopen the connection.

Overrides: asyncore.dispatcher.handle_close

handle_read(self)

source code 
Overrides: asyncore.dispatcher.handle_read

handle_error(self)

source code 

Overload asyncore's exception handling

Overrides: asyncore.dispatcher.handle_error

collect_incoming_data(self, data)

source code 

asynchat calls this with data as it comes in

Overrides: asynchat.async_chat.collect_incoming_data

_chunk_start_data(self)

source code 

        overload asynchat.found_terminator for
        _STATE_CHUNKED_START
        Assumes we got a hit on terminator '
'