This PR contains the following updates:
| Package | Type | Update | Change |
|---|---|---|---|
| tower-http | dependencies | minor | 0.6 → 0.7 |
Release Notes
tower-rs/tower-http (tower-http)
v0.7.1
Added
fs: addServeDir::redirect_to_trailing_slash()to serve directory indexes directly instead of first redirecting to the trailing-slash path. The redirect remains the default (#728)fs: addignore_multi_range_requests()toServeDirandServeFile, serving the full representation when a request asks for multiple byte ranges. The existing416 Range Not Satisfiableresponse remains the default (#727)request-id: the constructors and accessors on the request-id layers, services, andRequestIdare nowconst fn, so they can be used in const context (#716)
Changed
fs: the minimumhttp-range-headerrequirement is now 0.4.2 (#661)
Fixed
- behavioral change:
fs: makeServeDir::try_callpropagate expected filesystem I/O errors when no fallback is configured, as documented, instead of converting them to404 Not Foundresponses (#718) decompression: don't end the body when a data frame with no remaining bytes arrives after the decompressor reports end-of-stream. Trailers following such a frame were dropped and could not be recovered (#722)decompression: return a body error when a data frame with remaining bytes arrives after the decompressor reports end-of-stream, rather than silently truncating. This regressed in 0.7.0 (#712)fs: multipart range requests are now rejected before range validation, so they consistently return416 Range Not Satisfiablewith aCannot serve multipart range requestsbody instead of a generic unsatisfiable-range response (#661)fs: range error responses no longer carry representation headers such asContent-TypeandContent-Encoding(#727)set-header:SetMultipleResponseHeadersLayerandSetMultipleResponseHeaderare nowCloneregardless of the response body type, matching the fix applied to the request-side types in 0.7.0 (#714)
All the changes
- chore(deps): bump actions/checkout from 6 to 7 by @dependabot[bot] in #708
- fix(compression): reject non-empty data frames after codec is EOF by @seanmonstar in #712
- Remove Clone derivations from SetMultipleResponseHeader* types by @skeet70 in #714
- feat(request-id): Allow request-id constructor in const context by @tottoto in #716
- fs: Avoid unnecessary conversions between SystemTime and HttpDate by @tottoto in #717
- fs: Use HeaderValue::is_empty to check for empty values by @tottoto in #720
- fs: Use HeaderValue::to_str for date headers by @tottoto in #721
- chore(deps): bump taiki-e/install-action from 2 to 2.85.4 by @dependabot[bot] in #715
- chore(deps): bump taiki-e/install-action from 2.85.4 to 2.85.12 by @dependabot[bot] in #723
- docs(example)/custom future with multiple bodies by @Reza-Darius in #711
- fix(decompression): don't end the body on an empty data frame by @clemenslosbichler-cloud in #722
- Propagate ServeDir::try_call I/O errors by @Boulea7 in #718
- ci: Update to cargo-check-external-types 0.5.0 by @tottoto in #724
- fix: reject multipart ranges before validation by @shblue21 in #661
- chore(deps): bump taiki-e/install-action from 2.85.12 to 2.86.3 by @dependabot[bot] in #726
- feat(services): configure directory redirects by @BreezeDelegate in #728
- Allow ignoring unsupported multi-range requests by @BreezeDelegate in #727
- chore(deps): bump taiki-e/install-action from 2.86.3 to 2.86.8 by @dependabot[bot] in #730
- chore(release): prepare 0.7.1 by @jlizen in #729
New Contributors
- @skeet70 made their first contribution in #714
- @Reza-Darius made their first contribution in #711
- @clemenslosbichler-cloud made their first contribution in #722
- @Boulea7 made their first contribution in #718
- @shblue21 made their first contribution in #661
- @BreezeDelegate made their first contribution in #728
v0.7.0
Added
-
csrf: add cross-site request forgery (CSRF) protection middleware, porting the cross-origin protection scheme introduced in Go 1.25 (#699)use tower::ServiceBuilder; use tower_http::csrf::CsrfLayer; // Rejects cross-origin state-changing requests using `Sec-Fetch-Site`, // an `Origin` allow-list, and an `Origin`/`Host` fallback. No per-request // token state required. let layer = CsrfLayer::new().add_trusted_origin("https://example.com")?; let service = ServiceBuilder::new().layer(layer).service_fn(handler); -
timeout: addDeadlineBodyfor non-resetting body timeouts, applied via the newRequestBodyDeadlineLayerandResponseBodyDeadlineLayer(#688)Unlike
TimeoutBody, which resets its deadline on every frame,DeadlineBodycaps the total time of a body transfer. A slow client trickling one byte at a time never trips an idle timeout but will trip a deadline.use std::time::Duration; use tower::ServiceBuilder; use tower_http::timeout::RequestBodyDeadlineLayer; // Abort the request body transfer after 30s total, regardless of how // frequently data arrives. let service = ServiceBuilder::new() .layer(RequestBodyDeadlineLayer::new(Duration::from_secs(30))) .service_fn(handler); -
fs: add strongETagsupport toServeDir, includingIf-MatchandIf-None-Matchprecondition handling per RFC 9110.304 Not Modifiedresponses now carry theETagandLast-Modifiedvalidators (#691) -
fs: add aBackendtrait to makeServeDirwork with non-filesystem sources (e.g. embedded assets or object storage). The defaultTokioBackendpreserves existing behavior. UseServeDir::with_backend()to plug in custom implementations (#684)use tower_http::services::fs::ServeDir; // `MyBackend` implements `tower_http::services::fs::Backend`. // The default `ServeDir::new()` continues to use `TokioBackend` (local FS). let service = ServeDir::with_backend("assets", MyBackend::new()); -
fs: addhtml_as_default_extensionoption toServeDir, appending.htmlwhen the request path has no extension (#519) -
fs: addredirect_path_prefixoption toServeDir, prepending a prefix on trailing-slash redirects so the service can be mounted under a sub-path (#486) -
validate-request: addValidateRequestHeaderLayer::has_header_value()to reject requests when a header does not have an expected value (#360) -
body:UnsyncBoxBody::new()constructor andFrom<ServeFileSystemResponseBody>conversion to avoid double-boxing when combiningServeDirresponses with other body types (#537) -
limit: implementDefaultforlimit::ResponseBodywhen the wrapped body also implementsDefault(#679)
Changed
-
breaking:
compression: the middleware now handles the*wildcard andidentity;q=0in Accept-Encoding per RFC 9110 §12.5.3. Requests that previously fell back to identity (e.g.*;q=0oridentity;q=0with no other acceptable encoding) now receive a 406 Not Acceptable response. Clients that explicitly reject all encodings without listing an alternative will see different behavior. (#693) -
breaking:
compression: upgrade theSizeAbovepredicate threshold fromu16tou64, allowing minimum sizes above 64 KiB (#704) -
breaking: remove the implicit no-op
tokioandasync-compressionfeatures. These were kept as no-op features in 0.6.x for backwards compatibility after the switch todep:syntax in #642. Downstream crates that activatetower-http/tokioortower http/async-compressionshould remove those feature entries; the underlying dependencies are still pulled in transitively by the features that need them (e.g.compression-gzip,fs,timeout). (#628) -
breaking:
trace/classify: include the gRPC error message in tracing output.GrpcCodeandGrpcFailureClassare now#[non_exhaustive], andGrpcStatusis exported from theclassifymodule (#422) -
breaking:
follow-redirect:FollowRedirectnow forwards requestExtensionsto redirected requests instead of dropping them. TheStandardpolicy drops extensions on cross-origin redirections (same-origin keeps them). Opt out withFollowRedirectLayer::preserve_extensions(false); keep specific types withFilterCredentials::allow_extension::<T>()or all of them withkeep_all_extensions(). (#706)use tower_http::follow_redirect::FollowRedirectLayer; // 0.7.0 forwards request `Extensions` across redirects by default. // Restore the previous behavior (drop all extensions) with: let layer = FollowRedirectLayer::new().preserve_extensions(false); -
breaking:
follow-redirect: header and extension filtering is now cumulative. A value a policy drops on one hop is no longer replayed on later hops, soFilterCredentialsno longer re-sendsCookie/Authorizationto a same-origin target reached after cross-origin hop. CustomPolicy::on_requestimpls now see the previous hop's filtered request, not the original. (#706) -
trace:DefaultOnRequest,DefaultOnResponse,DefaultOnFailure, andDefaultOnEosnow explicitly parent their tracing events to the request span rather than relying on the ambient span context. This fixes intermittent cases where events could appear without their request span attached (#690) -
cors: relax theVaryheader defaults (#674) -
MSRV bumped from 1.64 to 1.65 (#684)
Fixed
fs:ServeDirandServeFilenow emit aVary: Accept-Encodingresponse header when precompressed serving is configured, ensuring caches correctly distinguish between compressed and uncompressed variants (#692)- breaking:
services: reject a trailing slash for file paths. File requests with a trailing slash now return404 Not Foundinstead of serving the file (#678) fs: fixServeDirstripping the file extension when serving with identity encoding (#686)compression: forward trailers from the inner body after compression finishes, fixing dropped gRPC status trailers (#685)trace: fireon_eoswhen the inner body reportsis_end_streamwith a precise content-length (#687)on-early-drop: suppress the early-drop guard whenis_end_streamis reported after a data frame (#687)set-header: makeSetMultipleRequestHeadersandSetMultipleResponseHeadersClonefor non-CloneHTTP bodies (#703)
Thanks
New Contributors
- @muhamadazmy made their first contribution in #679
- @Isvane made their first contribution in #678
- @xiaoyawei made their first contribution in #422
- @dependabot[bot] made their first contribution in #696
- @its-the-shrimp made their first contribution in #519
- @yawn made their first contribution in #699
- @Jesse-Bakker made their first contribution in #703
- @junghwan16 made their first contribution in #705
- @claraphyll made their first contribution in #486
Configuration
📅 Schedule: (UTC)
- Branch creation
- At any time (no schedule defined)
- Automerge
- At any time (no schedule defined)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
- If you want to rebase/retry this PR, check this box
This PR was generated by Mend Renovate. View the repository job log.
Activity
6Skipping PR review because a bot author is detected.
If you want to trigger CodeAnt AI, comment @codeant-ai review to trigger a manual review.
IMPORTANT
Review skipped
Bot user detected.
To trigger a single review, invoke the
@coderabbitai reviewcommand.
Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
c9bddfbf-6286-4d3a-bc8e-f3903fe3f247You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- Trigger review
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
- (https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- Mastodon
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Current Aviator status
Aviator will automatically update this comment as the status of the PR changes. Comment
/aviator refreshto force Aviator to re-examine your PR (or learn about other/aviatorcommands).
This pull request is currently open (not queued).
How to merge
To merge this PR, comment /aviator merge or add the mergequeue label.
PR author is in the excluded authors list.