Module httplib
[show private | hide private]
[frames | no frames]

Module httplib

HTTP/1.1 client library

############################################################
patched for use with co2 to use socket.settimeout by default
modifications are marked '# co2 patch'
############################################################

<intro stuff goes here>
<other stuff, too>

HTTPConnection go through a number of "states", which defines when a client
may legally make another request or fetch the response for a particular
request. This diagram details these state transitions:

    (null)
      |
      | HTTPConnection()
      v
    Idle
      |
      | putrequest()
      v
    Request-started
      |
      | ( putheader() )*  endheaders()
      v
    Request-sent
      |
      | response = getresponse()
      v
    Unread-response   [Response-headers-read]
      |\____________________
      |                     |
      | response.read()     | putrequest()
      v                     v
    Idle                  Req-started-unread-response
                     ______/|
                   /        |
   response.read() |        | ( putheader() )*  endheaders()
                   v        v
       Request-started    Req-sent-unread-response
                            |
                            | response.read()
                            v
                          Request-sent

This diagram presents the following rules:
  -- a second request may not be started until {response-headers-read}
  -- a response [object] cannot be retrieved until {request-sent}
  -- there is no differentiation between an unread response body and a
     partially read response body

Note: this enforcement is applied by the HTTPConnection class. The
      HTTPResponse class does not enforce this state machine, which
      implies sophisticated clients may accelerate the request/response
      pipeline. Caution should be taken, though: accelerating the states
      beyond the above pattern may imply knowledge of the server's
      connection-close behavior for certain requests. For example, it
      is impossible to tell whether the server will close the connection
      UNTIL the response headers have been read; this means that further
      requests cannot be placed into the pipeline until it is known that
      the server will NOT be closing the connection.

Logical State                  __state            __response
-------------                  -------            ----------
Idle                           _CS_IDLE           None
Request-started                _CS_REQ_STARTED    None
Request-sent                   _CS_REQ_SENT       None
Unread-response                _CS_IDLE           <response_class>
Req-started-unread-response    _CS_REQ_STARTED    <response_class>
Req-sent-unread-response       _CS_REQ_SENT       <response_class>

Classes
HTTP Compatibility class with httplib.py from 1.5.
HTTPResponse  
HTTPConnection  
HTTPSConnection This class allows communication via SSL.
FakeSocket  
HTTPMessage  
HTTPS Compatibility with 1.5 httplib interface
LineAndFileWrapper A limited file-like object for HTTP/0.9 responses.
SharedSocket  
SharedSocketClient  
SSLFile File-like object wrapping an SSL socket.

Exceptions
HTTPException  
NotConnected  
UnknownProtocol  
UnknownTransferEncoding  
UnimplementedFileMode  
IncompleteRead  
InvalidURL  
ImproperConnectionState  
CannotSendRequest  
CannotSendHeader  
ResponseNotReady  
BadStatusLine  
error  

Function Summary
  test()
Test this module.

Variable Summary
int HTTP_PORT
int HTTPS_PORT
float SOCKET_TIMEOUT
str _CS_IDLE
str _CS_REQ_SENT
str _CS_REQ_STARTED
str _UNKNOWN

Function Details

test()

Test this module.

A hodge podge of tests collected here, because they have too many external dependencies for the regular test suite.

Variable Details

HTTP_PORT

Type:
int
Value:
80                                                                     

HTTPS_PORT

Type:
int
Value:
443                                                                    

SOCKET_TIMEOUT

Type:
float
Value:
20.0                                                                   

_CS_IDLE

Type:
str
Value:
'Idle'                                                                 

_CS_REQ_SENT

Type:
str
Value:
'Request-sent'                                                         

_CS_REQ_STARTED

Type:
str
Value:
'Request-started'                                                      

_UNKNOWN

Type:
str
Value:
'UNKNOWN'                                                              

Generated by Epydoc 1.1 on Thu Oct 16 16:37:23 2003 http://epydoc.sf.net