Merge "Include object sysmeta in POST responses"
This commit is contained in:
commit
dd512a3207
@ -47,7 +47,7 @@ from swift.common.base_storage_server import BaseStorageServer
|
|||||||
from swift.common.header_key_dict import HeaderKeyDict
|
from swift.common.header_key_dict import HeaderKeyDict
|
||||||
from swift.common.request_helpers import get_name_and_placement, \
|
from swift.common.request_helpers import get_name_and_placement, \
|
||||||
is_user_meta, is_sys_or_user_meta, is_object_transient_sysmeta, \
|
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, \
|
from swift.common.swob import HTTPAccepted, HTTPBadRequest, HTTPCreated, \
|
||||||
HTTPInternalServerError, HTTPNoContent, HTTPNotFound, \
|
HTTPInternalServerError, HTTPNoContent, HTTPNotFound, \
|
||||||
HTTPPreconditionFailed, HTTPRequestTimeout, HTTPUnprocessableEntity, \
|
HTTPPreconditionFailed, HTTPRequestTimeout, HTTPUnprocessableEntity, \
|
||||||
@ -630,7 +630,14 @@ class ObjectController(BaseStorageServer):
|
|||||||
self.container_update(
|
self.container_update(
|
||||||
'PUT', account, container, obj, request, update_headers,
|
'PUT', account, container, obj, request, update_headers,
|
||||||
device, policy)
|
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
|
@public
|
||||||
@timing_stats()
|
@timing_stats()
|
||||||
|
@ -187,6 +187,7 @@ class TestObjectController(unittest.TestCase):
|
|||||||
'Foo': 'fooheader',
|
'Foo': 'fooheader',
|
||||||
'Baz': 'bazheader',
|
'Baz': 'bazheader',
|
||||||
'X-Object-Sysmeta-Color': 'blue',
|
'X-Object-Sysmeta-Color': 'blue',
|
||||||
|
'X-Object-Transient-Sysmeta-Shape': 'circle',
|
||||||
'X-Object-Meta-1': 'One',
|
'X-Object-Meta-1': 'One',
|
||||||
'X-Object-Meta-Two': 'Two'}
|
'X-Object-Meta-Two': 'Two'}
|
||||||
req = Request.blank('/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
|
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), {
|
self.assertEqual(dict(resp.headers), {
|
||||||
'Content-Type': 'text/html; charset=UTF-8',
|
'Content-Type': 'text/html; charset=UTF-8',
|
||||||
'Content-Length': str(len(resp.body)),
|
'Content-Length': str(len(resp.body)),
|
||||||
|
'X-Object-Sysmeta-Color': 'blue',
|
||||||
})
|
})
|
||||||
|
|
||||||
req = Request.blank('/sda1/p/a/c/o')
|
req = Request.blank('/sda1/p/a/c/o')
|
||||||
@ -257,6 +259,7 @@ class TestObjectController(unittest.TestCase):
|
|||||||
self.assertEqual(dict(resp.headers), {
|
self.assertEqual(dict(resp.headers), {
|
||||||
'Content-Type': 'text/html; charset=UTF-8',
|
'Content-Type': 'text/html; charset=UTF-8',
|
||||||
'Content-Length': str(len(resp.body)),
|
'Content-Length': str(len(resp.body)),
|
||||||
|
'X-Object-Sysmeta-Color': 'blue',
|
||||||
})
|
})
|
||||||
|
|
||||||
req = Request.blank('/sda1/p/a/c/o')
|
req = Request.blank('/sda1/p/a/c/o')
|
||||||
@ -331,6 +334,7 @@ class TestObjectController(unittest.TestCase):
|
|||||||
self.assertEqual(dict(resp.headers), {
|
self.assertEqual(dict(resp.headers), {
|
||||||
'Content-Type': 'text/html; charset=UTF-8',
|
'Content-Type': 'text/html; charset=UTF-8',
|
||||||
'Content-Length': str(len(resp.body)),
|
'Content-Length': str(len(resp.body)),
|
||||||
|
'X-Object-Sysmeta-Color': 'red',
|
||||||
})
|
})
|
||||||
|
|
||||||
req = Request.blank('/sda1/p/a/c/o')
|
req = Request.blank('/sda1/p/a/c/o')
|
||||||
@ -363,6 +367,7 @@ class TestObjectController(unittest.TestCase):
|
|||||||
self.assertEqual(dict(resp.headers), {
|
self.assertEqual(dict(resp.headers), {
|
||||||
'Content-Type': 'text/html; charset=UTF-8',
|
'Content-Type': 'text/html; charset=UTF-8',
|
||||||
'Content-Length': str(len(resp.body)),
|
'Content-Length': str(len(resp.body)),
|
||||||
|
'X-Object-Sysmeta-Color': 'red',
|
||||||
})
|
})
|
||||||
|
|
||||||
req = Request.blank('/sda1/p/a/c/o')
|
req = Request.blank('/sda1/p/a/c/o')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user