[Python-checkins] cpython (2.7): merge from 3.2 - Fix closes issue12524 - update http.client POST example with a
senthil.kumaran
python-checkins at python.org
Wed Jul 20 16:02:52 CEST 2011
http://hg.python.org/cpython/rev/b754641a429f
changeset: 71438:b754641a429f
branch: 2.7
parent: 71434:213a28b1f346
user: Senthil Kumaran <senthil at uthcode.com>
date: Wed Jul 20 22:02:27 2011 +0800
summary:
merge from 3.2 - Fix closes issue12524 - update http.client POST example with a working example. - Patch contributed by Bharadwaj
files:
Doc/library/httplib.rst | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Doc/library/httplib.rst b/Doc/library/httplib.rst
--- a/Doc/library/httplib.rst
+++ b/Doc/library/httplib.rst
@@ -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 <a href="http://bugs.python.org/issue12524">http://bugs.python.org/issue12524</a>'
>>> conn.close()
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list