Limit maximum HTTP Range header to fileSize #198
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some HTTP servers do not support Range requests when the Range header is longer than the actual length of the file. Examples of servers that don't support it are Aliyun OSS (see #196 and examples below, and it looks like node-static also doesn't support it).
I was reading through RFC 7233: Range Requests but it doesn't seem to say anything about what servers should do when the byte range is longer than the file range. So I guess Aliyun OSS is technically in the spec when they don't support it, and it's something we need to handle on the client side.
Fixes #196
Example
The length of the following file is
44515988
bytes.Returns HTTP 200
The following HTTP range request returns HTTP 200 and downloads the entire file since the end of the range is past the end of the file.
Returns HTTP 206
The following command returns HTTP 206 and works correctly.