Skip to content

Commit

Permalink
test: fix test for invalid etag in if-range.
Browse files Browse the repository at this point in the history
The broken etag was missing the initial ", so the wrong code path was
duplicated. Also add test that correct size of file was returned and
fix comment(s).
  • Loading branch information
rouilj committed Mar 17, 2024
1 parent 7ab7d19 commit 461ee46
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/test_liveserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def test_byte_Ranges(self):
self.assertEqual(f.headers['content-range'],
"bytes 10-20/%s"%expected_length)

# get all bytest starting from 11
# get all bytes starting from 11
hdrs = {"Range": "bytes=11-"}
f = requests.get(self.url_base() + "/@@file/style.css", headers=hdrs)
self.assertEqual(f.status_code, 206)
Expand Down Expand Up @@ -269,10 +269,11 @@ def test_byte_Ranges(self):

# range is too large, but etag is bad also, return whole file 200 code
hdrs['Range'] = "0-99999" # too large
hdrs['If-Range'] = etag[2:] # bad tag
hdrs['If-Range'] = '"' + etag[2:] # start bad tag with "
f = requests.get(self.url_base() + "/@@file/style.css", headers=hdrs)
self.assertEqual(f.status_code, 200)
# not checking content length since it could be compressed
# note f.content has content-encoding (compression) undone.
self.assertEqual(len(f.content), int(expected_length))
self.assertNotIn('content-range', f.headers, 'content-range should not be present')

# range is too large, but etag is specified so return whole file
Expand Down

0 comments on commit 461ee46

Please sign in to comment.