diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2013-03-13 20:30:25 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2013-03-13 20:30:25 (GMT) |
commit | 69c66f9a431e32df9e713eee1021ef1954a9be60 (patch) | |
tree | b580750233832ce8247df8bee387828fb9f9d88c /Doc | |
parent | 5e32424b491f94bc155e19a4da1f8d93804464a5 (diff) | |
download | cpython-69c66f9a431e32df9e713eee1021ef1954a9be60.zip cpython-69c66f9a431e32df9e713eee1021ef1954a9be60.tar.gz cpython-69c66f9a431e32df9e713eee1021ef1954a9be60.tar.bz2 |
#17307 - Example of HTTP PUT Request using httplib
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/httplib.rst | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Doc/library/httplib.rst b/Doc/library/httplib.rst index 1e37cdf..472fa61 100644 --- a/Doc/library/httplib.rst +++ b/Doc/library/httplib.rst @@ -612,3 +612,20 @@ Here is an example session that shows how to ``POST`` requests:: '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 httplib:: + + >>> # This creates an HTTP message + >>> # with the content of BODY as the enclosed representation + >>> # for the resource http://localhost:8080/foobar + ... + >>> import httplib + >>> BODY = "***filecontents***" + >>> conn = httplib.HTTPConnection("localhost", 8080) + >>> conn.request("PUT", "/file", BODY) + >>> response = conn.getresponse() + >>> print resp.status, response.reason + 200, OK + |