[Python-checkins] CVS: python/dist/src/Doc/lib libhttplib.tex,1.19,1.20

Fred L. Drake python-dev@python.org
2000年6月28日 14:51:46 -0700


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv5474/lib
Modified Files:
	libhttplib.tex 
Log Message:
Skip Montanaro <skip@mojam.com>:
Added an example of using an HTTP POST request.
Index: libhttplib.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libhttplib.tex,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** libhttplib.tex	1999年04月22日 16:47:27	1.19
--- libhttplib.tex	2000年06月28日 21:51:43	1.20
***************
*** 115,119 ****
 \nodename{HTTP Example}
 
! Here is an example session:
 
 \begin{verbatim}
--- 115,119 ----
 \nodename{HTTP Example}
 
! Here is an example session that uses the \samp{GET} method:
 
 \begin{verbatim}
***************
*** 129,131 ****
--- 129,148 ----
 >>> data = f.read() # Get the raw HTML
 >>> f.close()
+ \end{verbatim}
+ 
+ Here is an example session that shows how to \samp{POST} requests:
+ 
+ \begin{verbatim}
+ >>> import httplib, urllib
+ >>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
+ >>> h = httplib.HTTP("www.musi-cal.com:80")
+ >>> h.putrequest("POST", "/cgi-bin/query")
+ >>> h.putheader("Content-length", "%d" % len(params))
+ >>> h.putheader('Accept', 'text/plain')
+ >>> h.putheader('Host', 'www.musi-cal.com')
+ >>> h.endheaders()
+ >>> h.send(paramstring)
+ >>> reply, msg, hdrs = h.getreply()
+ >>> print errcode # should be 200
+ >>> data = h.getfile().read() # get the raw HTML
 \end{verbatim}

AltStyle によって変換されたページ (->オリジナル) /