]> granicus.if.org Git - python/commitdiff
Fix closes issue12524 - update http.client POST example with a working example.
authorSenthil Kumaran <senthil@uthcode.com>
Wed, 20 Jul 2011 13:56:24 +0000 (21:56 +0800)
committerSenthil Kumaran <senthil@uthcode.com>
Wed, 20 Jul 2011 13:56:24 +0000 (21:56 +0800)
Doc/library/http.client.rst

index 54873ae30487d9f8decec5e0bbbc24adc1659c4e..3749ff2d80025e1661f62c862be92943438b3dcf 100644 (file)
@@ -592,15 +592,17 @@ Here is an example session that uses the ``HEAD`` method.  Note that the
 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()