Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable cors/tests.rs and make it pass #473

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make requested changes and add bugfix to changelog
  • Loading branch information
glendc committed Feb 22, 2024
commit 1b83720b7f9eccffba620655cab5c5d4c774f1fc
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])
jplatte marked this conversation as resolved.
Show resolved Hide resolved

[#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);
}
Loading