s3api: fix canonical_string for Date and X-Amz-Date header handling
canonical_string needs to reset the Date header if it sees the X-Amz-Date header.
This commit is contained in:
parent
866ffd39f6
commit
6efeab60d9
@ -128,13 +128,23 @@ def canonical_string(req):
|
|||||||
"""
|
"""
|
||||||
Canonicalize a request to a token that can be signed.
|
Canonicalize a request to a token that can be signed.
|
||||||
"""
|
"""
|
||||||
|
amz_headers = {}
|
||||||
|
|
||||||
buf = "%s\n%s\n%s\n" % (req.method, req.headers.get('Content-MD5', ''),
|
buf = "%s\n%s\n%s\n" % (req.method, req.headers.get('Content-MD5', ''),
|
||||||
req.headers.get('Content-Type') or '')
|
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
|
for amz_header in sorted((key.lower() for key in req.headers
|
||||||
if key.lower().startswith('x-amz-'))):
|
if key.lower().startswith('x-amz-'))):
|
||||||
buf += "%s:%s\n" % (amz_header, req.headers[amz_header])
|
amz_headers[amz_header] = req.headers[amz_header]
|
||||||
|
|
||||||
|
if 'x-amz-date' in amz_headers:
|
||||||
|
buf += "\n"
|
||||||
|
elif 'Date' in req.headers:
|
||||||
|
buf += "%s\n" % req.headers['Date']
|
||||||
|
|
||||||
|
for k in sorted(key.lower() for key in amz_headers):
|
||||||
|
buf += "%s:%s\n" % (k, amz_headers[k])
|
||||||
|
|
||||||
path = req.path_qs
|
path = req.path_qs
|
||||||
if '?' in path:
|
if '?' in path:
|
||||||
path, args = path.split('?', 1)
|
path, args = path.split('?', 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user