swift3 missing content type fix

This commit is contained in:
Michael Barton 2011-03-31 05:53:44 +00:00
parent bfc490f624
commit fc3e894cbd
2 changed files with 16 additions and 1 deletions

View File

@ -132,7 +132,7 @@ def canonical_string(req):
Canonicalize a request to a token that can be signed.
"""
buf = "%s\n%s\n%s\n" % (req.method, req.headers.get('Content-MD5', ''),
req.headers.get('Content-Type', ''))
req.headers.get('Content-Type') or '')
if 'Date' in req.headers:
buf += "%s\n" % req.headers['Date']
for amz_header in sorted((key.lower() for key in req.headers

View File

@ -580,5 +580,20 @@ class TestSwift3(unittest.TestCase):
'X-Amz-Z': 'whatever', 'X-Amz-B': 'lalala',
'X-Amz-Y': 'lalalalalalala'})
verify('7506d97002c7d2de922cc0ec34af8846', '/bucket/object',
{'Content-Type': '', 'X-Amz-Something': 'test'})
req1 = Request.blank('/', headers=
{'Content-Type': None, 'X-Amz-Something': 'test'})
req2 = Request.blank('/', headers=
{'Content-Type': '', 'X-Amz-Something': 'test'})
req3 = Request.blank('/', headers={'X-Amz-Something': 'test'})
self.assertEquals(swift3.canonical_string(req1),
swift3.canonical_string(req2))
self.assertEquals(swift3.canonical_string(req2),
swift3.canonical_string(req3))
if __name__ == '__main__':
unittest.main()