home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / pyhtmldoc / h / httplib < prev   
Encoding:
Text File  |  1996-11-14  |  2.0 KB  |  47 lines

  1. <TITLE>httplib -- Python library reference</TITLE>
  2. Next: <A HREF="../f/ftplib" TYPE="Next">ftplib</A>  
  3. Prev: <A HREF="../u/urllib" TYPE="Prev">urllib</A>  
  4. Up: <A HREF="../i/internet_and_www" TYPE="Up">Internet and WWW</A>  
  5. Top: <A HREF="../t/top" TYPE="Top">Top</A>  
  6. <H1>10.3. Standard Module <CODE>httplib</CODE></H1>
  7. This module defines a class which implements the client side of the
  8. HTTP protocol.  It is normally not used directly --- the module
  9. <CODE>urllib</CODE> uses it to handle URLs that use HTTP.
  10. The module defines one class, <CODE>HTTP</CODE>.  An <CODE>HTTP</CODE> instance
  11. represents one transaction with an HTTP server.  It should be
  12. instantiated passing it a host and optional port number.  If no port
  13. number is passed, the port is extracted from the host string if it has
  14. the form <CODE>host:port</CODE>, else the default HTTP port (80) is used.
  15. If no host is passed, no connection is made, and the <CODE>connect</CODE>
  16. method should be used to connect to a server.  For example, the
  17. following calls all create instances that connect to the server at the
  18. same host and port:
  19. <P>
  20. <UL COMPACT><CODE>>>> h1 = httplib.HTTP('www.cwi.nl')<P>
  21. >>> h2 = httplib.HTTP('www.cwi.nl:80')<P>
  22. >>> h3 = httplib.HTTP('www.cwi.nl', 80)<P>
  23. </CODE></UL>
  24. Once an <CODE>HTTP</CODE> instance has been connected to an HTTP server, it
  25. should be used as follows:
  26. <P>
  27. <UL>
  28. <LI>1. 1.  Make exactly one call to the <CODE>putrequest()</CODE> method.
  29. <P>
  30. <LI>2. 2.  Make zero or more calls to the <CODE>putheader()</CODE> method.
  31. <P>
  32. <LI>3. 3.  Call the <CODE>endheaders()</CODE> method (this can be omitted if
  33. step 4 makes no calls).
  34. <P>
  35. <LI>4. 4.  Optional calls to the <CODE>send()</CODE> method.
  36. <P>
  37. <LI>5. 5.  Call the <CODE>getreply()</CODE> method.
  38. <P>
  39. <LI>6. 6.  Call the <CODE>getfile()</CODE> method and read the data off the
  40. file object that it returns.
  41. <P>
  42. </UL>
  43. <H2>Menu</H2><DL COMPACT>
  44. <DT><A HREF="../h/http_objects" TYPE=Menu>HTTP Objects</A>
  45. <DD><DT><A HREF="../h/http_example" TYPE=Menu>HTTP Example</A>
  46. <DD></DL>
  47.