diff options
author | Daniel G. Taylor <dan@programmer-art.org> | 2014-08-22 10:51:24 -0700 |
---|---|---|
committer | Daniel G. Taylor <dan@programmer-art.org> | 2014-08-22 10:51:24 -0700 |
commit | 885348da54738b7e0d93cd2b0bfe4c2b40c85ed6 (patch) | |
tree | 73b077962b614dfe57d4eae9e737be83b723f368 | |
parent | bd0d6dbae8ada6dd92e28a69d639adf1bfe359f5 (diff) | |
parent | b161f611081e9dc4369d53cc12957137fe6a9579 (diff) | |
download | boto-885348da54738b7e0d93cd2b0bfe4c2b40c85ed6.tar.gz |
Merge pull request #2521 from danielgtaylor/header-bytes
Support auth when headers contains bytes. Fixes #2521, #2520.
-rw-r--r-- | boto/auth.py | 2 | ||||
-rw-r--r-- | tests/unit/auth/test_sigv4.py | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/boto/auth.py b/boto/auth.py index 6012962a..bc8290d7 100644 --- a/boto/auth.py +++ b/boto/auth.py @@ -317,6 +317,8 @@ class HmacAuthV4Handler(AuthHandler, HmacKeys): for name, value in http_request.headers.items(): lname = name.lower() if lname.startswith('x-amz'): + if isinstance(value, bytes): + value = value.decode('utf-8') headers_to_sign[name] = value return headers_to_sign diff --git a/tests/unit/auth/test_sigv4.py b/tests/unit/auth/test_sigv4.py index 674ec0a7..7b4afa5c 100644 --- a/tests/unit/auth/test_sigv4.py +++ b/tests/unit/auth/test_sigv4.py @@ -251,6 +251,17 @@ class TestSigV4Handler(unittest.TestCase): auth2 = pickle.loads(pickled) self.assertEqual(auth.host, auth2.host) + def test_bytes_header(self): + auth = HmacAuthV4Handler('glacier.us-east-1.amazonaws.com', + mock.Mock(), self.provider) + request = HTTPRequest( + 'GET', 'http', 'glacier.us-east-1.amazonaws.com', 80, + 'x/./././x .html', None, {}, + {'x-amz-glacier-version': '2012-06-01', 'x-amz-hash': b'f00'}, '') + canonical = auth.canonical_request(request) + + self.assertIn('f00', canonical) + class TestS3HmacAuthV4Handler(unittest.TestCase): def setUp(self): |