Merge "Improve swift headers handling"

This commit is contained in:
Zuul 2022-10-26 09:56:42 +00:00 committed by Gerrit Code Review
commit 57fbb72e32
2 changed files with 13 additions and 1 deletions

View File

@ -84,7 +84,10 @@ class BaseResource(resource.Resource):
self.metadata = dict()
for header in headers:
if header.startswith(self._custom_metadata_prefix):
# RADOS and other stuff in front may actually lowcase headers
if header.lower().startswith(
self._custom_metadata_prefix.lower()
):
key = header[len(self._custom_metadata_prefix):].lower()
self.metadata[key] = headers[header]

View File

@ -116,6 +116,15 @@ class TestObject(base_test_object.BaseTestObject):
self.assertEqual(self.headers['Content-Type'], sot.content_type)
self.assertEqual(self.headers['X-Delete-At'], sot.delete_at)
# Verify that we also properly process lowcased headers
# All headers are processed in _base._set_metadata therefore invoke it
# here directly
sot._set_metadata(headers={"x-object-meta-foo": "bar"})
self.assert_no_calls()
# Attributes from header
self.assertEqual("bar", sot.metadata["foo"])
def test_download(self):
headers = {
'X-Newest': 'True',