dlo: Respond 200 on multi-range GETs
We already had a unit test for this, but it was inadvertently retesting what test_get_suffix_range_many_segments tested. Change-Id: I43eee7029ca884268c3f2ad74300b94b299fd8d2 Closes-Bug: #1831790
This commit is contained in:
parent
2a54619609
commit
a21c0be70c
@ -304,6 +304,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
|
||||||
|
@ -117,6 +117,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, b"e")
|
self.assertEqual(file_contents, b"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')
|
||||||
|
|
||||||
|
@ -478,14 +478,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, b'aaaaabbbbbcccccdddddeeeee')
|
self.assertEqual(body, b'aaaaabbbbbcccccdddddeeeee')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user