| httplib | index /usr/lib/python1.6/httplib.py |
HTTP client class
See the following URL for a description of the HTTP/1.0 protocol:
http://www.w3.org/hypertext/WWW/Protocols/
(I actually implemented it from a much earlier draft.)
Example:
>>> from httplib import HTTP
>>> h = HTTP('www.python.org')
>>> h.putrequest('GET', '/index.html')
>>> h.putheader('Accept', 'text/html')
>>> h.putheader('Accept', 'text/plain')
>>> h.endheaders()
>>> errcode, errmsg, headers = h.getreply()
>>> if errcode == 200:
... f = h.getfile()
... print f.read() # Print the raw HTML
...
<HEAD>
<TITLE>Python Language Home Page</TITLE>
[...many more lines...]
>>>
Note that an HTTP object is used for a single request -- to issue a
second request to the same server, you create a new HTTP object.
(This is in accordance with the protocol, which uses a new TCP
connection for each request.)
| Modules | ||||||
| ||||||
| Classes | ||||||||||||||||||
| ||||||||||||||||||
| Functions | ||
| ||
| Data | ||
| HTTPS_PORT = 443 HTTP_PORT = 80 HTTP_VERSION = 'HTTP/1.0' __file__ = '/usr/lib/python1.6/httplib.pyc' __name__ = 'httplib' | ||