Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Various fixes in _mexe:

Logging the http request body: if the body is >1024 bytes, only the first 1024 bytes are logged, together with the total size of the body. This to prevent logging MB or even GB sized bodies like when uploading files. The first 1024 bytes should be enough to see whether the body is as expected.

Log e instead of e.__class__.__name__ when an error is encountered, to have an actual error name (e.__class__.__name__ results in 'error' which is not exactly useful).

If the request.body is a file-like object (e.g. an mmapped file), the seek pointer must be reset to 0 before retrying. Otherwise this gives problems calculating the hash for the authentication signature.
  • Loading branch information...
commit 48979742e27b3ae8fc55dfcea569d40d4c524929 1 parent 9c82c9d
wvmarle authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 boto/connection.py
13 boto/connection.py
View
@@ -786,7 +786,10 @@ def _mexe(self, request, sender=None, override_num_retries=None,
"""
boto.log.debug('Method: %s' % request.method)
boto.log.debug('Path: %s' % request.path)
- boto.log.debug('Data: %s' % request.body)
+ if len(request.body) > 128:
+ boto.log.debug('Data (first 1024 of %s bytes): %s' % (len(request.body), request.body[0:1024]))
+ else:
+ boto.log.debug('Data: %s' % request.body)
boto.log.debug('Headers: %s' % request.headers)
boto.log.debug('Host: %s' % request.host)
response = None
@@ -854,10 +857,12 @@ def _mexe(self, request, sender=None, override_num_retries=None,
if isinstance(e, unretryable):
boto.log.debug(
'encountered unretryable %s exception, re-raising' %
- e.__class__.__name__)
+ e)
raise e
boto.log.debug('encountered %s exception, reconnecting' % \
- e.__class__.__name__)
+ e)
+ if hasattr(request.body, 'seek'):
+ request.body.seek(0)
connection = self.new_http_connection(request.host,
self.is_secure)
time.sleep(next_sleep)
@@ -952,7 +957,7 @@ def make_request(self, action, params=None, path='/', verb='GET'):
return self._mexe(http_request)
def build_list_params(self, params, items, label):
- if isinstance(items, str):
+ if isinstance(items, basestring):
items = [items]
for i in range(1, len(items) + 1):
params['%s.%d' % (label, i)] = items[i - 1]
Please sign in to comment.
Something went wrong with that request. Please try again.