Repository navigation
Skip unsatisfiable ranges when at least one range is satisfiable - #1257
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
DefaultServlet returned 416 for a multi-range request as soon as one range-spec was unsatisfiable, e.g. "bytes=0-1,200-300" for a 100 byte resource. RFC 9110, section 14.1.1 defines a ranges-specifier as satisfiable if at least one range-spec is satisfiable, section 14.2 then calls for a 206 response with the satisfiable ranges and section 15.5.17 limits 416 to the case where none of the ranges are satisfiable. Unsatisfiable range-specs are now skipped. Invalid range-specs are still rejected.
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.
DefaultServlet returns 416 for a multi-range request as soon as one range-spec is unsatisfiable. For a 100 byte resource,
Range: bytes=0-1,200-300gets 416 although0-1can be served.RFC 9110, section 14.1.1: "A valid ranges-specifier is "satisfiable" if it contains at least one range-spec that is satisfiable". Section 14.2 then calls for a 206 with the satisfiable range-spec(s), section 15.5.17 limits 416 to the case where none of the ranges are satisfiable and section 15.3.7.2 excludes unsatisfiable ranges from a multipart response.
Unsatisfiable range-specs are now skipped before validation. Invalid range-specs (last-pos less than first-pos) are still rejected and a request with no satisfiable range still gets 416.
Tested on a local Tomcat:
bytes=0-1,200-300bytes 0-1/100bytes=200-300,0-1bytes 0-1/100bytes=0-1,200-300,4-50-1and4-5bytes=200-300bytes=200-100,0-1Tests added to TestDefaultServletRangeRequests fail without the change.