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/d7152c78 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/d7152c78 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/d7152c78 Branch: refs/heads/0.13.2 Commit: d7152c78bfd59e4722fea7304d1b62029abcd395 Parents: bca5762 Author: Tomaz Muraus <[email protected]> Authored: Thu Sep 12 17:35:31 2013 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Fri Sep 13 15:20:23 2013 +0200 ---------------------------------------------------------------------- libcloud/common/base.py | 6 ++++++ 1 file changed, 6 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/d7152c78/libcloud/common/base.py ---------------------------------------------------------------------- diff --git a/libcloud/common/base.py b/libcloud/common/base.py index f32f3ec..f3ecfb6 100644 --- a/libcloud/common/base.py +++ b/libcloud/common/base.py @@ -595,6 +595,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)
