Skip to content

Commit

Permalink
make requested changes and add bugfix to changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
glendc committed Feb 22, 2024
1 parent a7399be commit 1b83720
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tower-http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Fixed

- **compression:** Skip compression for range requests ([#446])
- **cors:** don't overwrite previously-set (Vary) value ([#473])

[#399]: https://github.com/tower-rs/tower-http/pull/399
[#446]: https://github.com/tower-rs/tower-http/pull/446
[#473]: https://github.com/tower-rs/tower-http/pull/473

# 0.5.1 (January 14, 2024)

Expand Down
4 changes: 2 additions & 2 deletions tower-http/src/cors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ where

// vary header can have multiple values, don't overwrite
// previously-set value(s).
if let Some(vary) = response_headers.remove(header::VARY) {
headers.append(header::VARY, vary);
if let Some(vary) = headers.remove(header::VARY) {
response_headers.append(header::VARY, vary);
}
// extend will overwrite previous headers of remaining names
response_headers.extend(headers.drain());
Expand Down
2 changes: 1 addition & 1 deletion tower-http/src/cors/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async fn vary_set_by_inner_service() {
let svc = CorsLayer::permissive().layer(service_fn(inner_svc));
let res = svc.oneshot(Request::new(Body::empty())).await.unwrap();
let mut vary_headers = res.headers().get_all(header::VARY).into_iter();
assert_eq!(vary_headers.next(), Some(&PERMISSIVE_CORS_VARY_HEADERS));
assert_eq!(vary_headers.next(), Some(&CUSTOM_VARY_HEADERS));
assert_eq!(vary_headers.next(), Some(&PERMISSIVE_CORS_VARY_HEADERS));
assert_eq!(vary_headers.next(), None);
}

0 comments on commit 1b83720

Please sign in to comment.