Don't send Content-Length header if len(data) == 0 and default all data arguments to None.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/fd76cf64 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/fd76cf64 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/fd76cf64 Branch: refs/heads/0.12.x Commit: fd76cf64c26fbbe865eb281699bbf6def2032ed2 Parents: e998c39 Author: Tomaz Muraus <[email protected]> Authored: Fri Jun 14 22:30:09 2013 -0700 Committer: Tomaz Muraus <[email protected]> Committed: Fri Jun 14 23:22:10 2013 -0700 ---------------------------------------------------------------------- libcloud/common/base.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/fd76cf64/libcloud/common/base.py ---------------------------------------------------------------------- diff --git a/libcloud/common/base.py b/libcloud/common/base.py index a2c6b15..464bec8 100644 --- a/libcloud/common/base.py +++ b/libcloud/common/base.py @@ -592,10 +592,8 @@ class Connection(object): headers.update({'Host': self.host}) # Encode data if necessary - if data != '' and data is not None: + if data: data = self.encode_data(data) - - if data is not None: headers.update({'Content-Length': str(len(data))}) params, headers = self.pre_connect_hook(params, headers) @@ -692,7 +690,7 @@ class PollingConnection(Connection): timeout = 200 request_method = 'request' - def async_request(self, action, params=None, data='', headers=None, + def async_request(self, action, params=None, data=None, headers=None, method='GET', context=None): """ Perform an 'async' request to the specified path. Keep in mind that @@ -758,7 +756,7 @@ class PollingConnection(Connection): return response - def get_request_kwargs(self, action, params=None, data='', headers=None, + def get_request_kwargs(self, action, params=None, data=None, headers=None, method='GET', context=None): """ Arguments which are passed to the initial request() call inside
