Merge "dlo: Respond 200 on multi-range GETs" into stable/queens

This commit is contained in:
Zuul 2019-10-25 07:41:51 +00:00 committed by Gerrit Code Review
commit 26077479de
3 changed files with 14 additions and 3 deletions

View File

@ -281,6 +281,8 @@ class GetContext(WSGIContext):
actual_content_length = None actual_content_length = None
content_length_for_swob_range = None content_length_for_swob_range = None
req.range = None req.range = None
else:
req.range = None
response_headers = [ response_headers = [
(h, v) for h, v in response_headers (h, v) for h, v in response_headers

View File

@ -118,6 +118,15 @@ class TestDlo(Base):
file_contents = file_item.read(size=1, offset=47) file_contents = file_item.read(size=1, offset=47)
self.assertEqual(file_contents, "e") 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): def test_get_range_out_of_range(self):
file_item = self.env.container.file('man1') file_item = self.env.container.file('man1')

View File

@ -476,14 +476,14 @@ class TestDloGetManifest(DloTestCase):
def test_get_multi_range(self): def test_get_multi_range(self):
# DLO doesn't support multi-range GETs. The way that you express that # 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. # 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'}, environ={'REQUEST_METHOD': 'GET'},
headers={'Range': 'bytes=5-9,15-19'}) headers={'Range': 'bytes=5-9,15-19'})
with mock.patch(LIMIT, 3): with mock.patch(LIMIT, 30):
status, headers, body = self.call_dlo(req) status, headers, body = self.call_dlo(req)
headers = HeaderKeyDict(headers) headers = HeaderKeyDict(headers)
self.assertEqual(status, "200 OK") 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.assertIsNone(headers.get("Content-Range"))
self.assertEqual(body, "aaaaabbbbbcccccdddddeeeee") self.assertEqual(body, "aaaaabbbbbcccccdddddeeeee")