diff options
author | Tim Burke <tim.burke@gmail.com> | 2016-08-17 16:01:23 -0700 |
---|---|---|
committer | Tim Burke <tim@swiftstack.com> | 2016-08-19 19:53:11 +0000 |
commit | 8fbe118cea8804fe29529a27f3937af412b47fb7 (patch) | |
tree | c23aad2a95887f311e0fd8203840c2146c3ee17d | |
parent | b1539d9c0feaaf26783e7cab3962219e036994ba (diff) | |
download | python-swiftclient-8fbe118cea8804fe29529a27f3937af412b47fb7.tar.gz |
Strip leading/trailing whitespace from headers
New versions of requests will raise an InvalidHeader error otherwise.
Change-Id: Idf3bcd8ac359bdda9a847bf99a78988943374134
Closes-Bug: #1614280
Closes-Bug: #1613814
-rw-r--r-- | swiftclient/service.py | 2 | ||||
-rw-r--r-- | tests/unit/test_service.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/swiftclient/service.py b/swiftclient/service.py index 6ccba55..3820ace 100644 --- a/swiftclient/service.py +++ b/swiftclient/service.py @@ -280,7 +280,7 @@ def split_headers(options, prefix=''): for item in options: split_item = item.split(':', 1) if len(split_item) == 2: - headers[(prefix + split_item[0]).title()] = split_item[1] + headers[(prefix + split_item[0]).title()] = split_item[1].strip() else: raise SwiftError( "Metadata parameter %s must contain a ':'.\n%s" diff --git a/tests/unit/test_service.py b/tests/unit/test_service.py index 2e7acf9..989699f 100644 --- a/tests/unit/test_service.py +++ b/tests/unit/test_service.py @@ -496,7 +496,7 @@ class TestServiceUtils(unittest.TestCase): self.assertEqual(opt_c['key'], 'key') def test_split_headers(self): - mock_headers = ['color:blue', 'size:large'] + mock_headers = ['color:blue', 'SIZE: large'] expected = {'Color': 'blue', 'Size': 'large'} actual = swiftclient.service.split_headers(mock_headers) |