Copyright (C) 2000-2012 |
GNU Info (python2.1-lib.info)httplibHTTP protocol client ==================== HTTP protocol client (requires sockets). This module defines a class which implements the client side of the HTTP protocol. It is normally not used directly -- the module `urllib' uses it to handle URLs that use HTTP. The module defines one class, `HTTP': `HTTP([host[, port]])' An `HTTP' instance represents one transaction with an HTTP server. It should be instantiated passing it a host and optional port number. If no port number is passed, the port is extracted from the host string if it has the form `HOST:PORT', else the default HTTP port (80) is used. If no host is passed, no connection is made, and the `connect()' method should be used to connect to a server. For example, the following calls all create instances that connect to the server at the same host and port: >>> h1 = httplib.HTTP('www.cwi.nl') >>> h2 = httplib.HTTP('www.cwi.nl:80') >>> h3 = httplib.HTTP('www.cwi.nl', 80) Once an `HTTP' instance has been connected to an HTTP server, it should be used as follows: 1. 1. Make exactly one call to the `putrequest()' method. 2. 2. Make zero or more calls to the `putheader()' method. 3. 3. Call the `endheaders()' method (this can be omitted if step 4 makes no calls). 4. 4. Optional calls to the `send()' method. 5. 5. Call the `getreply()' method. 6. 6. Call the `getfile()' method and read the data off the file object that it returns. automatically generated by info2www version 1.2.2.9 |