Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3e446127
Commit
3e446127
authored
Jul 20, 2011
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Plain Diff
merge from 3.2 - Fix closes issue12524 - update http.client POST example with a working example.
parents
fb96089b
96c84a4c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
Doc/library/http.client.rst
Doc/library/http.client.rst
+6
-4
No files found.
Doc/library/http.client.rst
View file @
3e446127
...
...
@@ -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()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment