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
e66cc817
Commit
e66cc817
authored
Mar 13, 2013
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Plain Diff
#17307 - merge from 3.2
parents
115309ac
b5fe2479
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
Doc/library/http.client.rst
Doc/library/http.client.rst
+18
-0
Doc/library/urllib.request.rst
Doc/library/urllib.request.rst
+9
-0
No files found.
Doc/library/http.client.rst
View file @
e66cc817
...
...
@@ -633,6 +633,24 @@ Here is an example session that shows how to ``POST`` requests::
b'Redirecting to <a href="http://bugs.python.org/issue12524">http://bugs.python.org/issue12524</a>'
>>> conn.close()
Client side ``HTTP PUT`` requests are very similar to ``POST`` requests. The
difference lies only the server side where HTTP server will allow resources to
be created via ``PUT`` request. It should be noted that custom HTTP methods
+are also handled in :class:`urllib.request.Request` by sending the appropriate
+method attribute.Here is an example session that shows how to do ``PUT``
request using http.client::
>>> # This creates an HTTP message
>>> # with the content of BODY as the enclosed representation
>>> # for the resource http://localhost:8080/foobar
...
>>> import http.client
>>> BODY = "***filecontents***"
>>> conn = http.client.HTTPConnection("localhost", 8080)
>>> conn.request("PUT", "/file", BODY)
>>> response = conn.getresponse()
>>> print(resp.status, response.reason)
200, OK
.. _httpmessage-objects:
...
...
Doc/library/urllib.request.rst
View file @
e66cc817
...
...
@@ -1109,6 +1109,15 @@ The code for the sample CGI used in the above example is::
data = sys.stdin.read()
print('Content-type: text-plain\n\nGot Data: "%s"' % data)
Here is an example of doing a ``PUT`` request using :class:`Request`::
import urllib.request
DATA=b'some data'
req = urllib.request.Request(url='http://localhost:8080', data=DATA,method='PUT')
f = urllib.request.urlopen(req)
print(f.status)
print(f.reason)
Use of Basic HTTP Authentication::
import urllib.request
...
...
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