home *** CD-ROM | disk | FTP | other *** search
- <TITLE>httplib -- Python library reference</TITLE>
- Next: <A HREF="../f/ftplib" TYPE="Next">ftplib</A>
- Prev: <A HREF="../u/urllib" TYPE="Prev">urllib</A>
- Up: <A HREF="../i/internet_and_www" TYPE="Up">Internet and WWW</A>
- Top: <A HREF="../t/top" TYPE="Top">Top</A>
- <H1>10.3. Standard Module <CODE>httplib</CODE></H1>
- This module defines a class which implements the client side of the
- HTTP protocol. It is normally not used directly --- the module
- <CODE>urllib</CODE> uses it to handle URLs that use HTTP.
- The module defines one class, <CODE>HTTP</CODE>. An <CODE>HTTP</CODE> 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 <CODE>host:port</CODE>, else the default HTTP port (80) is used.
- If no host is passed, no connection is made, and the <CODE>connect</CODE>
- 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:
- <P>
- <UL COMPACT><CODE>>>> h1 = httplib.HTTP('www.cwi.nl')<P>
- >>> h2 = httplib.HTTP('www.cwi.nl:80')<P>
- >>> h3 = httplib.HTTP('www.cwi.nl', 80)<P>
- </CODE></UL>
- Once an <CODE>HTTP</CODE> instance has been connected to an HTTP server, it
- should be used as follows:
- <P>
- <UL>
- <LI>1. 1. Make exactly one call to the <CODE>putrequest()</CODE> method.
- <P>
- <LI>2. 2. Make zero or more calls to the <CODE>putheader()</CODE> method.
- <P>
- <LI>3. 3. Call the <CODE>endheaders()</CODE> method (this can be omitted if
- step 4 makes no calls).
- <P>
- <LI>4. 4. Optional calls to the <CODE>send()</CODE> method.
- <P>
- <LI>5. 5. Call the <CODE>getreply()</CODE> method.
- <P>
- <LI>6. 6. Call the <CODE>getfile()</CODE> method and read the data off the
- file object that it returns.
- <P>
- </UL>
- <H2>Menu</H2><DL COMPACT>
- <DT><A HREF="../h/http_objects" TYPE=Menu>HTTP Objects</A>
- <DD><DT><A HREF="../h/http_example" TYPE=Menu>HTTP Example</A>
- <DD></DL>
-