Merge "Strip leading/trailing whitespace from headers"
This commit is contained in:
@@ -282,7 +282,7 @@ def split_headers(options, prefix=''):
|
|||||||
for item in options:
|
for item in options:
|
||||||
split_item = item.split(':', 1)
|
split_item = item.split(':', 1)
|
||||||
if len(split_item) == 2:
|
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:
|
else:
|
||||||
raise SwiftError(
|
raise SwiftError(
|
||||||
"Metadata parameter %s must contain a ':'.\n%s"
|
"Metadata parameter %s must contain a ':'.\n%s"
|
||||||
|
@@ -532,7 +532,7 @@ class TestServiceUtils(unittest.TestCase):
|
|||||||
self.assertEqual(opt_c['key'], 'key')
|
self.assertEqual(opt_c['key'], 'key')
|
||||||
|
|
||||||
def test_split_headers(self):
|
def test_split_headers(self):
|
||||||
mock_headers = ['color:blue', 'size:large']
|
mock_headers = ['color:blue', 'SIZE: large']
|
||||||
expected = {'Color': 'blue', 'Size': 'large'}
|
expected = {'Color': 'blue', 'Size': 'large'}
|
||||||
|
|
||||||
actual = swiftclient.service.split_headers(mock_headers)
|
actual = swiftclient.service.split_headers(mock_headers)
|
||||||
|
Reference in New Issue
Block a user