[Python-checkins] cpython (3.2): Fix closes issue12524 - update http.client POST example with a working example.
senthil.kumaran
python-checkins at python.org
Wed Jul 20 16:02:51 CEST 2011
http://hg.python.org/cpython/rev/ab4d403cb0c0
changeset: 71436:ab4d403cb0c0
branch: 3.2
parent: 71432:908efa044c2e
user: Senthil Kumaran <senthil at uthcode.com>
date: Wed Jul 20 21:56:24 2011 +0800
summary:
Fix closes issue12524 - update http.client POST example with a working example.
files:
Doc/library/http.client.rst | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst
--- a/Doc/library/http.client.rst
+++ b/Doc/library/http.client.rst
@@ -592,15 +592,17 @@
Here is an example session that shows how to ``POST`` requests::
>>> import http.client, urllib.parse
- >>> params = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
+ >>> params = urllib.parse.urlencode({'@number': 12524, '@type': 'issue', '@action': 'show'})
>>> headers = {"Content-type": "application/x-www-form-urlencoded",
... "Accept": "text/plain"}
- >>> conn = http.client.HTTPConnection("musi-cal.mojam.com:80")
- >>> conn.request("POST", "/cgi-bin/query", params, headers)
+ >>> conn = http.client.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
+ b'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