upgrade cookie to 0.18

with fix braking changes
This commit is contained in:
kazuk 2026-01-07 16:15:50 +09:00
parent afd53045d4
commit d42d01df0e
8 changed files with 21 additions and 27 deletions

18
Cargo.lock generated
View File

@ -82,7 +82,7 @@ dependencies = [
"actix-utils",
"actix-web",
"async-stream",
"base64 0.22.1",
"base64",
"bitflags 2.10.0",
"brotli",
"bytes",
@ -623,7 +623,7 @@ dependencies = [
"actix-tls",
"actix-utils",
"actix-web",
"base64 0.22.1",
"base64",
"brotli",
"bytes",
"cfg-if",
@ -680,12 +680,6 @@ dependencies = [
"fs_extra",
]
[[package]]
name = "base64"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5"
[[package]]
name = "base64"
version = "0.22.1"
@ -902,12 +896,12 @@ dependencies = [
[[package]]
name = "cookie"
version = "0.16.2"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb"
checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747"
dependencies = [
"aes-gcm",
"base64 0.20.0",
"base64",
"hkdf",
"hmac",
"percent-encoding",
@ -2142,7 +2136,7 @@ version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be"
dependencies = [
"base64 0.22.1",
"base64",
"serde_core",
]

View File

@ -141,7 +141,7 @@ actix-web-codegen = { version = "4.3", optional = true, default-features = false
bytes = "1"
bytestring = "1"
cfg-if = "1"
cookie = { version = "0.16", features = ["percent-encode"], optional = true }
cookie = { version = "0.18", features = ["percent-encode"], optional = true }
derive_more = { version = "2", features = ["as_ref", "deref", "deref_mut", "display", "error", "from"] }
encoding_rs = "0.8"
foldhash = "0.1"

View File

@ -228,12 +228,12 @@ impl HttpResponseBuilder {
///
/// let res = HttpResponse::Ok()
/// .cookie(
/// Cookie::build("name", "value")
/// Cookie::build(("name", "value"))
/// .domain("www.rust-lang.org")
/// .path("/")
/// .secure(true)
/// .http_only(true)
/// .finish(),
/// .build(),
/// )
/// .finish();
/// ```
@ -243,10 +243,10 @@ impl HttpResponseBuilder {
/// use actix_web::{HttpResponse, cookie::Cookie};
///
/// // the name, domain and path match the cookie created in the previous example
/// let mut cookie = Cookie::build("name", "value-does-not-matter")
/// let mut cookie = Cookie::build(("name", "value-does-not-matter"))
/// .domain("www.rust-lang.org")
/// .path("/")
/// .finish();
/// .build();
/// cookie.make_removal();
///
/// let res = HttpResponse::Ok()

View File

@ -745,9 +745,9 @@ async fn test_server_cookies() {
App::new().default_service(web::to(|| async {
HttpResponse::Ok()
.cookie(
Cookie::build("first", "first_value")
Cookie::build(("first", "first_value"))
.http_only(true)
.finish(),
.build(),
)
.cookie(Cookie::new("second", "first_value"))
.cookie(Cookie::new("second", "second_value"))
@ -760,9 +760,9 @@ async fn test_server_cookies() {
assert!(res.status().is_success());
{
let first_cookie = Cookie::build("first", "first_value")
let first_cookie = Cookie::build(("first", "first_value"))
.http_only(true)
.finish();
.build();
let second_cookie = Cookie::new("second", "first_value");
let cookies = res.cookies().expect("To have cookies");

View File

@ -123,7 +123,7 @@ serde_json = "1.0"
serde_urlencoded = "0.7"
tokio = { version = "1.38.2", features = ["sync"] }
cookie = { version = "0.16", features = ["percent-encode"], optional = true }
cookie = { version = "0.18", features = ["percent-encode"], optional = true }
tls-openssl = { package = "openssl", version = "0.10.55", optional = true }
tls-rustls-0_20 = { package = "rustls", version = "0.20", optional = true, features = ["dangerous_configuration"] }

View File

@ -108,7 +108,7 @@ mod tests {
let res = TestResponse::default()
.version(Version::HTTP_2)
.insert_header((header::DATE, HttpDate::from(SystemTime::now())))
.cookie(cookie::Cookie::build("name", "value").finish())
.cookie(cookie::Cookie::build(("name", "value")).build())
.finish();
assert!(res.headers().contains_key(header::SET_COOKIE));
assert!(res.headers().contains_key(header::DATE));

View File

@ -543,7 +543,7 @@ mod tests {
.protocols(["v1", "v2"])
.set_header_if_none(header::CONTENT_TYPE, "json")
.set_header_if_none(header::CONTENT_TYPE, "text")
.cookie(Cookie::build("cookie1", "value1").finish());
.cookie(Cookie::build(("cookie1", "value1")).build());
assert_eq!(
req.origin.as_ref().unwrap().to_str().unwrap(),
"test-origin"

View File

@ -667,13 +667,13 @@ async fn body_streaming_implicit() {
async fn client_cookie_handling() {
use std::io::{Error as IoError, ErrorKind};
let cookie1 = Cookie::build("cookie1", "value1").finish();
let cookie2 = Cookie::build("cookie2", "value2")
let cookie1 = Cookie::build(("cookie1", "value1")).build();
let cookie2 = Cookie::build(("cookie2", "value2"))
.domain("www.example.org")
.path("/")
.secure(true)
.http_only(true)
.finish();
.build();
// Q: are all these clones really necessary? A: Yes, possibly
let cookie1b = cookie1.clone();
let cookie2b = cookie2.clone();