summaryrefslogtreecommitdiffstats
path: root/Doc/libhttplib.tex
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-03-17 16:07:09 (GMT)
committerGuido van Rossum <guido@python.org>1995-03-17 16:07:09 (GMT)
commit470be14c8aa23a35a1f4d1f1260a66a85d3f3cd9 (patch)
tree4fd0b8eda81e63366598e55362ceac85adafccb4 /Doc/libhttplib.tex
parent7760cdea81166b7741561043c58dae171811fb2f (diff)
downloadcpython-470be14c8aa23a35a1f4d1f1260a66a85d3f3cd9.zip
cpython-470be14c8aa23a35a1f4d1f1260a66a85d3f3cd9.tar.gz
cpython-470be14c8aa23a35a1f4d1f1260a66a85d3f3cd9.tar.bz2
mass changes; fix titles; add examples; correct typos; clarifications;
unified style; etc.
Diffstat (limited to 'Doc/libhttplib.tex')
-rw-r--r--Doc/libhttplib.tex33
1 files changed, 30 insertions, 3 deletions
diff --git a/Doc/libhttplib.tex b/Doc/libhttplib.tex
index 0d7ac4f..46d791b 100644
--- a/Doc/libhttplib.tex
+++ b/Doc/libhttplib.tex
@@ -1,4 +1,4 @@
-\section{Built-in module \sectcode{httplib}}
+\section{Standard Module \sectcode{httplib}}
\stmodindex{httplib}
\index{HTTP}
@@ -15,7 +15,15 @@ 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}, else the default HTTP port (80) is used.
If no host is passed, no connection is made, and the \code{connect}
-method should be used to connect to a server.
+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:
+
+\begin{verbatim}
+>>> h1 = httplib.HTTP('www.cwi.nl')
+>>> h2 = httplib.HTTP('www.cwi.nl:80')
+>>> h3 = httplib.HTTP('www.cwi.nl', 80)
+\end{verbatim}
Once an \code{HTTP} instance has been connected to an HTTP server, it
should be used as follows:
@@ -27,7 +35,7 @@ should be used as follows:
\item[2.] Make zero or more calls to the \code{putheader()} method.
\item[3.] Call the \code{endheaders()} method (this can be omitted if
-step 4. makes no calls).
+step 4 makes no calls).
\item[4.] Optional calls to the \code{send()} method.
@@ -93,3 +101,22 @@ Return a file object from which the data returned by the server can be
read, using the \code{read()}, \code{readline()} or \code{readlines()}
methods.
\end{funcdesc}
+
+\subsection{Example}
+
+Here is an example session:
+
+\begin{verbatim}
+>>> import httplib
+>>> h = httplib.HTTP('www.cwi.nl')
+>>> h.putrequest('GET', '/index.html')
+>>> h.putheader('Accept', 'text/html')
+>>> h.putheader('Accept', 'text/plain')
+>>> h.endheaders()
+>>> errcode, errmsg, headers = h.getreply()
+>>> print errcode # Should be 200
+>>> f = h.getfile()
+>>> data f.read() # Get the raw HTML
+>>> f.close()
+>>>
+\end{verbatim}