Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
httplib Namespace Reference

Data Structures

class  HTTPResponse
 
class  HTTPConnection
 
class  FakeSocket
 
class  HTTPSConnection
 
class  HTTP
 
class  HTTPS
 
class  HTTPException
 
class  NotConnected
 
class  UnknownProtocol
 
class  UnknownTransferEncoding
 
class  IllegalKeywordArgument
 
class  UnimplementedFileMode
 
class  IncompleteRead
 
class  ImproperConnectionState
 
class  CannotSendRequest
 
class  CannotSendHeader
 
class  ResponseNotReady
 
class  BadStatusLine
 

Functions

def test
 

Variables

list __all__
 
int HTTP_PORT = 80
 
int HTTPS_PORT = 443
 
string _UNKNOWN = 'UNKNOWN'
 
string _CS_IDLE = 'Idle'
 
string _CS_REQ_STARTED = 'Request-started'
 
string _CS_REQ_SENT = 'Request-sent'
 
 error = HTTPException
 

Detailed Description

HTTP/1.1 client library

<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>

Function Documentation

def httplib.test ( )
Test this module.

The test consists of retrieving and displaying the Python
home page, along with the error code and error string returned
by the www.python.org server.

Definition at line 852 of file httplib.py.

853 def test():
854  """Test this module.
855 
856  The test consists of retrieving and displaying the Python
857  home page, along with the error code and error string returned
858  by the www.python.org server.
859  """
860 
861  import sys
862  import getopt
863  opts, args = getopt.getopt(sys.argv[1:], 'd')
864  dl = 0
865  for o, a in opts:
866  if o == '-d': dl = dl + 1
867  host = 'www.python.org'
868  selector = '/'
869  if args[0:]: host = args[0]
870  if args[1:]: selector = args[1]
871  h = HTTP()
872  h.set_debuglevel(dl)
873  h.connect(host)
874  h.putrequest('GET', selector)
875  h.endheaders()
876  status, reason, headers = h.getreply()
877  print 'status =', status
878  print 'reason =', reason
879  print
880  if headers:
881  for header in headers.headers: print header.strip()
882  print
883  print h.getfile().read()
884 
885  # minimal test that code to extract host from url works
886  class HTTP11(HTTP):
887  _http_vsn = 11
888  _http_vsn_str = 'HTTP/1.1'
889 
890  h = HTTP11('www.python.org')
891  h.putrequest('GET', 'http://www.python.org/~jeremy/')
892  h.endheaders()
893  h.getreply()
894  h.close()
895 
896  if hasattr(socket, 'ssl'):
897  host = 'sourceforge.net'
898  selector = '/projects/python'
899  hs = HTTPS()
900  hs.connect(host)
901  hs.putrequest('GET', selector)
902  hs.endheaders()
903  status, reason, headers = hs.getreply()
904  print 'status =', status
905  print 'reason =', reason
906  print
907  if headers:
908  for header in headers.headers: print header.strip()
909  print
910  print hs.getfile().read()
911 

Variable Documentation

list __all__
Initial value:
1 = ["HTTP", "HTTPResponse", "HTTPConnection", "HTTPSConnection",
2  "HTTPException", "NotConnected", "UnknownProtocol",
3  "UnknownTransferEncoding", "IllegalKeywordArgument",
4  "UnimplementedFileMode", "IncompleteRead",
5  "ImproperConnectionState", "CannotSendRequest", "CannotSendHeader",
6  "ResponseNotReady", "BadStatusLine", "error"]

Definition at line 79 of file httplib.py.

string _CS_IDLE = 'Idle'

Definition at line 92 of file httplib.py.

string _CS_REQ_SENT = 'Request-sent'

Definition at line 94 of file httplib.py.

string _CS_REQ_STARTED = 'Request-started'

Definition at line 93 of file httplib.py.

string _UNKNOWN = 'UNKNOWN'

Definition at line 89 of file httplib.py.

error = HTTPException

Definition at line 846 of file httplib.py.

int HTTP_PORT = 80

Definition at line 86 of file httplib.py.

int HTTPS_PORT = 443

Definition at line 87 of file httplib.py.