Skip to content

Commit 3e44612

Browse files
committed
merge from 3.2 - Fix closes issue12524 - update http.client POST example with a working example.
2 parents fb96089 + 96c84a4 commit 3e44612

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Doc/library/http.client.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,15 +592,17 @@ Here is an example session that uses the ``HEAD`` method. Note that the
592592
Here is an example session that shows how to ``POST`` requests::
593593

594594
>>> import http.client, urllib.parse
595-
>>> params = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
595+
>>> params = urllib.parse.urlencode({'@number': 12524, '@type': 'issue', '@action': 'show'})
596596
>>> headers = {"Content-type": "application/x-www-form-urlencoded",
597597
... "Accept": "text/plain"}
598-
>>> conn = http.client.HTTPConnection("musi-cal.mojam.com:80")
599-
>>> conn.request("POST", "/cgi-bin/query", params, headers)
598+
>>> conn = http.client.HTTPConnection("bugs.python.org")
599+
>>> conn.request("POST", "", params, headers)
600600
>>> response = conn.getresponse()
601601
>>> print(response.status, response.reason)
602-
200 OK
602+
302 Found
603603
>>> data = response.read()
604+
>>> data
605+
b'Redirecting to <a href="http://bugs.python.org/issue12524">http://bugs.python.org/issue12524</a>'
604606
>>> conn.close()
605607

606608

0 commit comments

Comments
 (0)