From 35d2cec919425d97d97724700834708d0f4f0c6e Mon Sep 17 00:00:00 2001 From: David Goetz Date: Wed, 3 Apr 2013 14:15:26 -0700 Subject: [PATCH] Bug in SLO with multipart-manifest=get content type. In trying to override the content-type for the convenience call I broke COPYs and POSTs for SLO. yaaa... Change-Id: Ifbcda6d2dd0ee43e43d62e58a90301e7afd05e27 --- swift/proxy/controllers/obj.py | 1 + test/unit/proxy/test_server.py | 50 ++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index b91e2fe7d6..16d5d62abb 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -403,6 +403,7 @@ class ObjectController(Controller): large_object = None if config_true_value(resp.headers.get('x-static-large-object')) and \ req.params.get('multipart-manifest') == 'get' and \ + 'X-Copy-From' not in req.headers and \ self.app.allow_static_large_object: resp.content_type = 'application/json' diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index e1ed81a525..36cd1ef0e7 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -1090,6 +1090,56 @@ class TestObjectController(unittest.TestCase): ['HEAD', '/a/c', {}], ['GET', '/a/c/manifest', {'multipart-manifest': 'get'}]]) + def test_GET_slo_multipart_manifest_from_copy(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', + headers={'x-copy-from': '/a/c/manifest'}) + resp = controller.GET(req) + self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.body, json_listing) + self.assertEqual(resp.content_type, 'text/html') + + self.assertEqual( + requested, + [['HEAD', '/a', {}], + ['HEAD', '/a/c', {}], + ['GET', '/a/c/manifest', {'multipart-manifest': 'get'}]]) + def test_GET_bad_etag_manifest_slo(self): listing = [{"hash": "98568d540134639be4655198a36614a4", "last_modified": "2012-11-08T04:05:37.866820",