changeset: 71438:b754641a429f branch: 2.7 parent: 71434:213a28b1f346 user: Senthil Kumaran date: Wed Jul 20 22:02:27 2011 +0800 files: Doc/library/httplib.rst description: merge from 3.2 - Fix closes issue12524 - update http.client POST example with a working example. - Patch contributed by Bharadwaj diff -r 213a28b1f346 -r b754641a429f Doc/library/httplib.rst --- a/Doc/library/httplib.rst Tue Jul 19 19:28:16 2011 -0400 +++ b/Doc/library/httplib.rst Wed Jul 20 22:02:27 2011 +0800 @@ -588,14 +588,16 @@ Here is an example session that shows how to ``POST`` requests:: >>> import httplib, urllib ->>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0}) +>>> params = urllib.urlencode({'@number': 12524, '@type': 'issue', '@action': 'show'}) >>> headers = {"Content-type": "application/x-www-form-urlencoded", ... "Accept": "text/plain"} ->>> conn = httplib.HTTPConnection("musi-cal.mojam.com:80") ->>> conn.request("POST", "/cgi-bin/query", params, headers) +>>> conn = httplib.HTTPConnection("bugs.python.org") +>>> conn.request("POST", "", params, headers) >>> response = conn.getresponse() >>> print response.status, response.reason - 200 OK + 302 Found >>> data = response.read() +>>> data + 'Redirecting to http://bugs.python.org/issue12524' >>> conn.close()

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