Skip to content

Allow ignoring unsupported multi-range requests - #727

Merged
jlizen merged 1 commit into
tower-rs:mainfrom
BreezeDelegate:fix/ignore-unsupported-multi-range
Aug 24, 2026
Merged

Allow ignoring unsupported multi-range requests#727
jlizen merged 1 commit into
tower-rs:mainfrom
BreezeDelegate:fix/ignore-unsupported-multi-range

Conversation

@BreezeDelegate

Copy link
Copy Markdown
Contributor

Motivation

ServeDir and ServeFile cannot produce multipart range responses. Returning 416 for a syntactically valid multi-range request is avoidable because RFC 9110 allows a server to ignore Range and serve the full representation.

Fixes #725.

Solution

Add an opt-in ignore_multi_range_requests setting to ServeDir and ServeFile. When enabled, syntactically valid multi-range headers are ignored before semantic range validation and the full representation is returned with 200; malformed headers and unsatisfiable single ranges keep returning 416.

The default remains unchanged. GET and HEAD behavior is covered, as are overlapping/reversed multi-ranges. 416 responses also stop retaining the selected representation's Content-Type and Content-Encoding, including for precompressed files.

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 jlizen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate it!


/// Configure whether syntactically valid multi-range requests should be ignored.
///
/// When enabled, a request containing multiple byte ranges is served as a normal full

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good docs, thanks.

.status(StatusCode::RANGE_NOT_SATISFIABLE)
.body(empty_body())
.unwrap();
response.headers_mut().remove(header::CONTENT_TYPE);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this

@jlizen
jlizen merged commit e2582e2 into tower-rs:main Aug 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore unsupported multi-range requests rather than erroring

2 participants