diff --git a/swift/common/middleware/dlo.py b/swift/common/middleware/dlo.py index 4c4ce00bff..0721b37eb9 100644 --- a/swift/common/middleware/dlo.py +++ b/swift/common/middleware/dlo.py @@ -281,6 +281,8 @@ class GetContext(WSGIContext): actual_content_length = None content_length_for_swob_range = None req.range = None + else: + req.range = None response_headers = [ (h, v) for h, v in response_headers diff --git a/test/functional/test_dlo.py b/test/functional/test_dlo.py index 75b76a3d50..4d44437f7d 100644 --- a/test/functional/test_dlo.py +++ b/test/functional/test_dlo.py @@ -118,6 +118,15 @@ class TestDlo(Base): file_contents = file_item.read(size=1, offset=47) self.assertEqual(file_contents, "e") + def test_get_multiple_ranges(self): + file_item = self.env.container.file('man1') + file_contents = file_item.read( + hdrs={'Range': 'bytes=0-4,10-14'}) + self.assert_status(200) # *not* 206 + self.assertEqual( + file_contents, + b"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeee") + def test_get_range_out_of_range(self): file_item = self.env.container.file('man1') diff --git a/test/unit/common/middleware/test_dlo.py b/test/unit/common/middleware/test_dlo.py index d0a4ccc8d6..308f04a81e 100644 --- a/test/unit/common/middleware/test_dlo.py +++ b/test/unit/common/middleware/test_dlo.py @@ -476,14 +476,14 @@ class TestDloGetManifest(DloTestCase): def test_get_multi_range(self): # DLO doesn't support multi-range GETs. The way that you express that # in HTTP is to return a 200 response containing the whole entity. - req = swob.Request.blank('/v1/AUTH_test/mancon/manifest-many-segments', + req = swob.Request.blank('/v1/AUTH_test/mancon/manifest', environ={'REQUEST_METHOD': 'GET'}, headers={'Range': 'bytes=5-9,15-19'}) - with mock.patch(LIMIT, 3): + with mock.patch(LIMIT, 30): status, headers, body = self.call_dlo(req) headers = HeaderKeyDict(headers) self.assertEqual(status, "200 OK") - self.assertIsNone(headers.get("Content-Length")) + self.assertEqual(headers.get("Content-Length"), '25') self.assertIsNone(headers.get("Content-Range")) self.assertEqual(body, "aaaaabbbbbcccccdddddeeeee")