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
This commit is contained in:
parent
b1539d9c0f
commit
8fbe118cea
@ -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"
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user