Skip to content

Commit

Permalink
Merge pull request #804 from JordonPhillips/s3-md5
Browse files Browse the repository at this point in the history
Don't use MD5 with s3v4
  • Loading branch information
JordonPhillips committed Feb 24, 2016
2 parents 71a9d8c + 7a31dd7 commit 2847bcd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion botocore/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _calculate_md5_from_file(fileobj):
def conditionally_calculate_md5(params, **kwargs):
"""Only add a Content-MD5 when not using sigv4"""
signer = kwargs['request_signer']
if signer.signature_version != 'v4':
if signer.signature_version not in ['v4', 's3v4']:
calculate_md5(params, **kwargs)


Expand Down
12 changes: 12 additions & 0 deletions tests/unit/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,18 @@ def test_does_not_add_md5_when_v4(self):
request_signer=request_signer)
self.assertTrue('Content-MD5' not in request_dict['headers'])

def test_does_not_add_md5_when_s3v4(self):
credentials = Credentials('key', 'secret')
request_signer = RequestSigner(
's3', 'us-east-1', 's3', 's3v4', credentials, mock.Mock())
request_dict = {'body': b'bar',
'url': 'https://s3.us-east-1.amazonaws.com',
'method': 'PUT',
'headers': {}}
handlers.conditionally_calculate_md5(request_dict,
request_signer=request_signer)
self.assertTrue('Content-MD5' not in request_dict['headers'])

def test_adds_md5_when_not_v4(self):
credentials = Credentials('key', 'secret')
request_signer = RequestSigner(
Expand Down

0 comments on commit 2847bcd

Please sign in to comment.