diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2013-03-13 20:38:33 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2013-03-13 20:38:33 (GMT) |
commit | b5fe2479c152c635e02897a7a5c72c97e4c22b6a (patch) | |
tree | 2755603e7d052f88e846c477dd4d7c034b3eeb04 /Doc/library/http.client.rst | |
parent | 67714629613159dbb24e584dcb1adbbc11027008 (diff) | |
download | cpython-b5fe2479c152c635e02897a7a5c72c97e4c22b6a.zip cpython-b5fe2479c152c635e02897a7a5c72c97e4c22b6a.tar.gz cpython-b5fe2479c152c635e02897a7a5c72c97e4c22b6a.tar.bz2 |
#17307 - Example of HTTP PUT Request using http.client
Diffstat (limited to 'Doc/library/http.client.rst')
-rw-r--r-- | Doc/library/http.client.rst | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst index d439f24..408a3e7 100644 --- a/Doc/library/http.client.rst +++ b/Doc/library/http.client.rst @@ -612,6 +612,22 @@ 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. 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: |