SLO multipart-manifest=get returns incorrect Content-Type
Change-Id: I657c9f7a7555d90ccfa7e6ff0f5f3fcbd7eada1d
This commit is contained in:
@@ -402,6 +402,11 @@ class ObjectController(Controller):
|
|||||||
resp.content_type = content_type
|
resp.content_type = content_type
|
||||||
|
|
||||||
large_object = None
|
large_object = None
|
||||||
|
if config_true_value(resp.headers.get('x-static-large-object')) and \
|
||||||
|
req.params.get('multipart-manifest') == 'get' and \
|
||||||
|
self.app.allow_static_large_object:
|
||||||
|
resp.content_type = 'application/json'
|
||||||
|
|
||||||
if config_true_value(resp.headers.get('x-static-large-object')) and \
|
if config_true_value(resp.headers.get('x-static-large-object')) and \
|
||||||
req.params.get('multipart-manifest') != 'get' and \
|
req.params.get('multipart-manifest') != 'get' and \
|
||||||
self.app.allow_static_large_object:
|
self.app.allow_static_large_object:
|
||||||
|
@@ -1041,6 +1041,55 @@ class TestObjectController(unittest.TestCase):
|
|||||||
['GET', '/a/d1/seg01', {}],
|
['GET', '/a/d1/seg01', {}],
|
||||||
['GET', '/a/d2/seg02', {}]])
|
['GET', '/a/d2/seg02', {}]])
|
||||||
|
|
||||||
|
def test_GET_slo_multipart_manifest(self):
|
||||||
|
listing = [{"hash": "98568d540134639be4655198a36614a4",
|
||||||
|
"last_modified": "2012-11-08T04:05:37.866820",
|
||||||
|
"bytes": 2,
|
||||||
|
"name": "/d1/seg01",
|
||||||
|
"content_type": "application/octet-stream"},
|
||||||
|
{"hash": "d526f1c8ef6c1e4e980e2b8471352d23",
|
||||||
|
"last_modified": "2012-11-08T04:05:37.846710",
|
||||||
|
"bytes": 2,
|
||||||
|
"name": "/d2/seg02",
|
||||||
|
"content_type": "application/octet-stream"}]
|
||||||
|
json_listing = simplejson.dumps(listing)
|
||||||
|
response_bodies = (
|
||||||
|
'', # HEAD /a
|
||||||
|
'', # HEAD /a/c
|
||||||
|
json_listing) # GET manifest
|
||||||
|
with save_globals():
|
||||||
|
controller = proxy_server.ObjectController(
|
||||||
|
self.app, 'a', 'c', 'manifest')
|
||||||
|
|
||||||
|
requested = []
|
||||||
|
|
||||||
|
def capture_requested_paths(ipaddr, port, device, partition,
|
||||||
|
method, path, headers=None,
|
||||||
|
query_string=None):
|
||||||
|
qs_dict = dict(urlparse.parse_qsl(query_string or ''))
|
||||||
|
requested.append([method, path, qs_dict])
|
||||||
|
|
||||||
|
set_http_connect(
|
||||||
|
200, # HEAD /a
|
||||||
|
200, # HEAD /a/c
|
||||||
|
200, # GET listing1
|
||||||
|
headers={"X-Static-Large-Object": "True",
|
||||||
|
'content-type': 'text/html; swift_bytes=4'},
|
||||||
|
body_iter=response_bodies,
|
||||||
|
give_connect=capture_requested_paths)
|
||||||
|
|
||||||
|
req = Request.blank('/a/c/manifest?multipart-manifest=get')
|
||||||
|
resp = controller.GET(req)
|
||||||
|
self.assertEqual(resp.status_int, 200)
|
||||||
|
self.assertEqual(resp.body, json_listing)
|
||||||
|
self.assertEqual(resp.content_type, 'application/json')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
requested,
|
||||||
|
[['HEAD', '/a', {}],
|
||||||
|
['HEAD', '/a/c', {}],
|
||||||
|
['GET', '/a/c/manifest', {'multipart-manifest': 'get'}]])
|
||||||
|
|
||||||
def test_GET_bad_etag_manifest_slo(self):
|
def test_GET_bad_etag_manifest_slo(self):
|
||||||
listing = [{"hash": "98568d540134639be4655198a36614a4",
|
listing = [{"hash": "98568d540134639be4655198a36614a4",
|
||||||
"last_modified": "2012-11-08T04:05:37.866820",
|
"last_modified": "2012-11-08T04:05:37.866820",
|
||||||
|
Reference in New Issue
Block a user