Allow ignoring unsupported multi-range requests - #727
Merged
jlizen merged 1 commit intoAug 24, 2026
Conversation
Add an opt-in for serving the full representation when a request contains multiple byte ranges. Keep the existing 416 behavior by default and strip representation headers from range errors. Fixes: tower-rs#725
jlizen
approved these changes
Aug 24, 2026
|
|
||
| /// Configure whether syntactically valid multi-range requests should be ignored. | ||
| /// | ||
| /// When enabled, a request containing multiple byte ranges is served as a normal full |
| .status(StatusCode::RANGE_NOT_SATISFIABLE) | ||
| .body(empty_body()) | ||
| .unwrap(); | ||
| response.headers_mut().remove(header::CONTENT_TYPE); |
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.
Motivation
ServeDirandServeFilecannot produce multipart range responses. Returning416for a syntactically valid multi-range request is avoidable because RFC 9110 allows a server to ignoreRangeand serve the full representation.Fixes #725.
Solution
Add an opt-in
ignore_multi_range_requestssetting toServeDirandServeFile. When enabled, syntactically valid multi-range headers are ignored before semantic range validation and the full representation is returned with200; malformed headers and unsatisfiable single ranges keep returning416.The default remains unchanged. GET and HEAD behavior is covered, as are overlapping/reversed multi-ranges.
416responses also stop retaining the selected representation'sContent-TypeandContent-Encoding, including for precompressed files.