Closed timj closed 1 year ago
I did have a quick look at the code and the error occurs in util.obtain_content_ranges
. The first match in the loop does correctly determine the first and last byte ranges but does not check to see if firstpos > filesize
. Instead it drops out of that block and then tries the second match with reSuffixByteRangeSpecifier.search
. This time it ends up doing firstpos = filesize - larger_number
and gets a negative answer which it then turns into firstpos = 0
and you end up with the whole file.
I did get the simple case to work by adding a check for firstpos > filesize
in the first check block and then immediately returning [], 0
-- what I'm not sure about is what should happen if you ask for multiple ranges and only one of them is unsatisfiable.
Yes, I also looked into it a bit yesterday. As I understand it, invalid Range headers may result in a
Content-Range: bytes */FILESIZE
I will try to get the latter working. (Multi-Part responses are currently not implemented btw.)
Describe the bug
If we request a byte range that is beyond the end of the file the server returns the full content of the file and ignores the byte range.
To Reproduce Steps to reproduce the behavior:
Run up a server with a small file in it:
(I have tried cheroot and uvicorn servers)
Use curl to request content:
This works:
Ask for a byte range that crosses the threshold and this works:
Now ask for a byte range that starts off the end of the file and this fails:
The entire file is returned as shown by the
Content-Range
header.The server is receiving the request properly:
Expected behavior
The expectation is that this should return status code 416. It should definitely not return the full content of the file.
For example requesting a file from GitHub:
Screenshots, Log-Files, Stacktrace
If applicable, add screenshots to help explain your problem. If applicable, add a log file (consider
--verbose
).Environment:
Which WSGI server was used (cheroot, ext-wsgiutils, gevent, gunicorn, paste, uvicorn, wsgiref, ...)?
cheroot and uvicorn.
Which WebDAV client was used (MS File Explorer, MS Office, macOS Finder, WinSCP, Windows, file mapping, ...)?
Simple curl.