Browse Source

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

stable/queens
Zuul Gerrit Code Review 4 months ago
parent
commit
26077479de
3 changed files with 14 additions and 3 deletions
  1. +2
    -0
      swift/common/middleware/dlo.py
  2. +9
    -0
      test/functional/test_dlo.py
  3. +3
    -3
      test/unit/common/middleware/test_dlo.py

+ 2
- 0
swift/common/middleware/dlo.py View File

@@ -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


+ 9
- 0
test/functional/test_dlo.py View File

@@ -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')



+ 3
- 3
test/unit/common/middleware/test_dlo.py View File

@@ -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")



Loading…
Cancel
Save