From: Senthil Kumaran Date: Wed, 13 Mar 2013 20:30:25 +0000 (-0700) Subject: #17307 - Example of HTTP PUT Request using httplib X-Git-Tag: v2.7.4rc1~38 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=69c66f9a431e32df9e713eee1021ef1954a9be60;p=thirdparty%2FPython%2Fcpython.git #17307 - Example of HTTP PUT Request using httplib --- diff --git a/Doc/library/httplib.rst b/Doc/library/httplib.rst index 1e37cdff78b7..472fa61e13dd 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 http://bugs.python.org/issue12524' >>> 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 +