mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-23 15:51:06 +01:00
fix(cors): The item in "Vary" header should be "Access-Control-Request-Private-Network". (#369)
* fix(cors): vary should be "Access-Control-Request-Private-Network" * docs(cors): update the changelog
This commit is contained in:
parent
5198c68c06
commit
2f30fd71a9
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- Fix `add_vary_header` to provide `Access-Control-Request-Private-Network`.
|
||||||
- Minimum supported Rust version (MSRV) is now 1.68.
|
- Minimum supported Rust version (MSRV) is now 1.68.
|
||||||
|
|
||||||
## 0.6.4
|
## 0.6.4
|
||||||
|
@ -223,7 +223,7 @@ pub(crate) fn add_vary_header(headers: &mut HeaderMap) {
|
|||||||
val.extend(b", Origin, Access-Control-Request-Method, Access-Control-Request-Headers");
|
val.extend(b", Origin, Access-Control-Request-Method, Access-Control-Request-Headers");
|
||||||
|
|
||||||
#[cfg(feature = "draft-private-network-access")]
|
#[cfg(feature = "draft-private-network-access")]
|
||||||
val.extend(b", Access-Control-Allow-Private-Network");
|
val.extend(b", Access-Control-Request-Private-Network");
|
||||||
|
|
||||||
val.try_into().unwrap()
|
val.try_into().unwrap()
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ pub(crate) fn add_vary_header(headers: &mut HeaderMap) {
|
|||||||
#[cfg(feature = "draft-private-network-access")]
|
#[cfg(feature = "draft-private-network-access")]
|
||||||
None => HeaderValue::from_static(
|
None => HeaderValue::from_static(
|
||||||
"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, \
|
"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, \
|
||||||
Access-Control-Allow-Private-Network",
|
Access-Control-Request-Private-Network",
|
||||||
),
|
),
|
||||||
|
|
||||||
#[cfg(not(feature = "draft-private-network-access"))]
|
#[cfg(not(feature = "draft-private-network-access"))]
|
||||||
|
@ -272,7 +272,7 @@ async fn test_response() {
|
|||||||
#[cfg(feature = "draft-private-network-access")]
|
#[cfg(feature = "draft-private-network-access")]
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(header::VARY).map(HeaderValue::as_bytes),
|
resp.headers().get(header::VARY).map(HeaderValue::as_bytes),
|
||||||
Some(&b"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network"[..]),
|
Some(&b"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Request-Private-Network"[..]),
|
||||||
);
|
);
|
||||||
|
|
||||||
#[allow(clippy::needless_collect)]
|
#[allow(clippy::needless_collect)]
|
||||||
@ -328,7 +328,7 @@ async fn test_response() {
|
|||||||
#[cfg(feature = "draft-private-network-access")]
|
#[cfg(feature = "draft-private-network-access")]
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(header::VARY).map(HeaderValue::as_bytes).unwrap(),
|
resp.headers().get(header::VARY).map(HeaderValue::as_bytes).unwrap(),
|
||||||
b"Accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network",
|
b"Accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Request-Private-Network",
|
||||||
);
|
);
|
||||||
|
|
||||||
let cors = Cors::default()
|
let cors = Cors::default()
|
||||||
@ -494,7 +494,7 @@ async fn vary_header_on_all_handled_responses() {
|
|||||||
.expect("response should have Vary header")
|
.expect("response should have Vary header")
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network",
|
"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Request-Private-Network",
|
||||||
);
|
);
|
||||||
|
|
||||||
// follow-up regular request
|
// follow-up regular request
|
||||||
@ -520,7 +520,7 @@ async fn vary_header_on_all_handled_responses() {
|
|||||||
.expect("response should have Vary header")
|
.expect("response should have Vary header")
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network",
|
"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Request-Private-Network",
|
||||||
);
|
);
|
||||||
|
|
||||||
let cors = Cors::default()
|
let cors = Cors::default()
|
||||||
@ -552,7 +552,7 @@ async fn vary_header_on_all_handled_responses() {
|
|||||||
.expect("response should have Vary header")
|
.expect("response should have Vary header")
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network",
|
"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Request-Private-Network",
|
||||||
);
|
);
|
||||||
|
|
||||||
// regular request no origin
|
// regular request no origin
|
||||||
@ -575,7 +575,7 @@ async fn vary_header_on_all_handled_responses() {
|
|||||||
.expect("response should have Vary header")
|
.expect("response should have Vary header")
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network",
|
"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Request-Private-Network",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user