[Python-checkins] cpython (2.7): #17307 - Example of HTTP PUT Request using httplib
senthil.kumaran
python-checkins at python.org
Wed Mar 13 21:40:31 CET 2013
http://hg.python.org/cpython/rev/4edde40afee6
changeset: 82650:4edde40afee6
branch: 2.7
parent: 82637:c226133b1493
user: Senthil Kumaran <senthil at uthcode.com>
date: Wed Mar 13 13:30:25 2013 -0700
summary:
#17307 - Example of HTTP PUT Request using httplib
files:
Doc/library/httplib.rst | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/Doc/library/httplib.rst b/Doc/library/httplib.rst
--- a/Doc/library/httplib.rst
+++ b/Doc/library/httplib.rst
@@ -612,3 +612,20 @@
'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
+
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list