Ignore Range values like "bytes=--0"
This is consistent with what we already do for other semantically-invalid values like "bytes=--1". Previously, we would return a 416 Requested Range Not Satisfiable response like we do for the semantically-valid-but-not-really-meaningful "bytes=-0" Change-Id: I932b42406c9a5ee7eaa6978a655e61022a957415
This commit is contained in:
parent
e55f3ad203
commit
c91ca5335f
@ -485,8 +485,10 @@ class Range(object):
|
||||
else:
|
||||
start = None
|
||||
if end:
|
||||
# when end contains non numeric value, this also causes
|
||||
# ValueError
|
||||
# We could just rely on int() raising the ValueError, but
|
||||
# this catches things like '--0'
|
||||
if not end.isdigit():
|
||||
raise ValueError('Invalid Range header: %s' % headerval)
|
||||
end = int(end)
|
||||
if end < 0:
|
||||
raise ValueError('Invalid Range header: %s' % headerval)
|
||||
|
@ -250,6 +250,7 @@ class TestRange(unittest.TestCase):
|
||||
"""
|
||||
|
||||
_assert_invalid_range(None)
|
||||
_assert_invalid_range('nonbytes=0-')
|
||||
_assert_invalid_range('nonbytes=foobar,10-2')
|
||||
_assert_invalid_range('bytes=5-3')
|
||||
_assert_invalid_range('bytes=-')
|
||||
@ -260,6 +261,7 @@ class TestRange(unittest.TestCase):
|
||||
_assert_invalid_range('bytes=nonumber-5')
|
||||
_assert_invalid_range('bytes=nonumber')
|
||||
_assert_invalid_range('bytes=--1')
|
||||
_assert_invalid_range('bytes=--0')
|
||||
|
||||
|
||||
class TestMatch(unittest.TestCase):
|
||||
|
Loading…
x
Reference in New Issue
Block a user