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/08/18 23:24:10 UTC
[4/4] git commit: Fix a bug with data encoding.
Fix a bug with data encoding.
encode_data shoud only be called if data is present.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/d173f21b
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/d173f21b
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/d173f21b
Branch: refs/heads/trunk
Commit: d173f21b896452f9921e7debc19ee54c00c0edf4
Parents: 99fd19a
Author: Tomaz Muraus <to...@apache.org>
Authored: Sun Aug 18 23:20:54 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sun Aug 18 23:20:54 2013 +0200
----------------------------------------------------------------------
libcloud/common/base.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/d173f21b/libcloud/common/base.py
----------------------------------------------------------------------
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index 609dd78..529bdbe 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -571,10 +571,12 @@ class Connection(object):
else:
headers.update({'Host': self.host})
- # Encode data if necessary
- if data is not None:
+ # Encode data if provided
+ if data:
data = self.encode_data(data)
- # Only send Content-Length 0 with POST and PUT request
+
+ # Only send Content-Length 0 with POST and PUT request
+ if data is not None:
if len(data) > 0 or (len(data) == 0 and method in ['POST', 'PUT']):
headers.update({'Content-Length': str(len(data))})