You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/09/12 19:20:34 UTC

[2/3] git commit: Add a comment which clarifies why Content-Length: 0 is not sent if "raw" mode is used.

Add a comment which clarifies why Content-Length: 0 is not sent if "raw" mode is
used.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/b3fb8f85
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/b3fb8f85
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/b3fb8f85

Branch: refs/heads/trunk
Commit: b3fb8f85186c8d3032a2ddaeaf32c820356a161f
Parents: 7179aac
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Sep 12 17:35:31 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Sep 12 17:43:44 2013 +0200

----------------------------------------------------------------------
 libcloud/common/base.py | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/b3fb8f85/libcloud/common/base.py
----------------------------------------------------------------------
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index 43cd82f..48e677b 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -575,6 +575,12 @@ class Connection(object):
             data = self.encode_data(data)
             headers['Content-Length'] = str(len(data))
         elif method.upper() in ['POST', 'PUT'] and not raw:
+            # Only send Content-Length 0 with POST and PUT request.
+            #
+            # Note: Content-Length is not added when using "raw" mode means
+            # means that headers are upfront and the body is sent at some point
+            # later on. With raw mode user can specify Content-Length with
+            # "data" not being set.
             headers['Content-Length'] = '0'
 
         params, headers = self.pre_connect_hook(params, headers)