mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Handle byte range with stop > content_length
This commit is contained in:
parent
3d51b47f57
commit
a02a437b1c
@ -47,6 +47,7 @@ def get_ranges(headervalue, content_length):
|
||||
continue
|
||||
if stop < start:
|
||||
continue
|
||||
stop = min(stop, content_length - 1)
|
||||
result.append(Range(start, stop, stop - start + 1))
|
||||
elif stop:
|
||||
# Negative subscript (last N bytes)
|
||||
|
@ -241,6 +241,10 @@ class TestHTTP(BaseTest):
|
||||
self.ae(type('')(r.getheader('Content-Range')), 'bytes */%d' % len(fdata))
|
||||
self.ae(r.status, httplib.REQUESTED_RANGE_NOT_SATISFIABLE)
|
||||
|
||||
conn.request('GET', '/test', headers={'Range':'bytes=0-1000000'})
|
||||
r = conn.getresponse()
|
||||
self.ae(r.status, httplib.PARTIAL_CONTENT), self.ae(r.read(), fdata)
|
||||
|
||||
conn.request('GET', '/test', headers={'Range':'bytes=25-50', 'If-Range':etag})
|
||||
r = conn.getresponse()
|
||||
self.ae(int(r.getheader('Content-Length')), 26)
|
||||
|
Loading…
x
Reference in New Issue
Block a user