Repository navigation
NamedFile: support If-Range - #39
Merged
Merged
Conversation
A resumed download with a stale If-Range got a 206 slice of the new file. Range now applies only when If-Range still matches the file.
4 tasks done
Member
|
thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A client that resumes a download with
RangeandIf-Rangeafter the file was replaced gets206with a slice of the new file and appends it to the old bytes. With this PR,Rangeis applied only whenIf-Rangestill matches the file; otherwise the client gets the whole file.What changes
W/"…"of the current tag inIf-Range, the response is200with noContent-Range(test: test_named_file_if_range_mismatch).Last-Modified(tests: test_named_file_if_range_mismatch, test_named_file_if_range_earlier_date).use_etag(false)is set, and for a date whenuse_last_modified(false)is set (test: test_named_file_if_range_mismatch).If-Rangeequal to the current strong ETag or toLast-Modifiedkeeps the206(test: test_named_file_if_range_match).Files, a non-matchingIf-Rangereturns the whole file with200for a satisfiable and for an unsatisfiableRange(test: test_files_if_range).Reference
actix-files fixed the same in actix/actix-web#4334.
This PR touches the same lines as "NamedFile: no panic on pre-epoch modification times or on an empty or degenerate Range" (
ntex-files/src/lib.rs) and "NamedFile: evaluate preconditions before Range" (ntex-files/src/named.rs); the one merged later needs a rebase.