Merge "Include object sysmeta in POST responses"

This commit is contained in:
Jenkins 2016-09-21 18:24:43 +00:00 committed by Gerrit Code Review
commit dd512a3207
2 changed files with 14 additions and 2 deletions

View File

@ -47,7 +47,7 @@ from swift.common.base_storage_server import BaseStorageServer
from swift.common.header_key_dict import HeaderKeyDict
from swift.common.request_helpers import get_name_and_placement, \
is_user_meta, is_sys_or_user_meta, is_object_transient_sysmeta, \
resolve_etag_is_at_header
resolve_etag_is_at_header, is_sys_meta
from swift.common.swob import HTTPAccepted, HTTPBadRequest, HTTPCreated, \
HTTPInternalServerError, HTTPNoContent, HTTPNotFound, \
HTTPPreconditionFailed, HTTPRequestTimeout, HTTPUnprocessableEntity, \
@ -630,7 +630,14 @@ class ObjectController(BaseStorageServer):
self.container_update(
'PUT', account, container, obj, request, update_headers,
device, policy)
return HTTPAccepted(request=request)
# Add sysmeta to response
resp_headers = {}
for key, value in orig_metadata.items():
if is_sys_meta('object', key):
resp_headers[key] = value
return HTTPAccepted(request=request, headers=resp_headers)
@public
@timing_stats()

View File

@ -187,6 +187,7 @@ class TestObjectController(unittest.TestCase):
'Foo': 'fooheader',
'Baz': 'bazheader',
'X-Object-Sysmeta-Color': 'blue',
'X-Object-Transient-Sysmeta-Shape': 'circle',
'X-Object-Meta-1': 'One',
'X-Object-Meta-Two': 'Two'}
req = Request.blank('/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
@ -217,6 +218,7 @@ class TestObjectController(unittest.TestCase):
self.assertEqual(dict(resp.headers), {
'Content-Type': 'text/html; charset=UTF-8',
'Content-Length': str(len(resp.body)),
'X-Object-Sysmeta-Color': 'blue',
})
req = Request.blank('/sda1/p/a/c/o')
@ -257,6 +259,7 @@ class TestObjectController(unittest.TestCase):
self.assertEqual(dict(resp.headers), {
'Content-Type': 'text/html; charset=UTF-8',
'Content-Length': str(len(resp.body)),
'X-Object-Sysmeta-Color': 'blue',
})
req = Request.blank('/sda1/p/a/c/o')
@ -331,6 +334,7 @@ class TestObjectController(unittest.TestCase):
self.assertEqual(dict(resp.headers), {
'Content-Type': 'text/html; charset=UTF-8',
'Content-Length': str(len(resp.body)),
'X-Object-Sysmeta-Color': 'red',
})
req = Request.blank('/sda1/p/a/c/o')
@ -363,6 +367,7 @@ class TestObjectController(unittest.TestCase):
self.assertEqual(dict(resp.headers), {
'Content-Type': 'text/html; charset=UTF-8',
'Content-Length': str(len(resp.body)),
'X-Object-Sysmeta-Color': 'red',
})
req = Request.blank('/sda1/p/a/c/o')