From 136569802efc00bda55b21aea61f917f309219e8 Mon Sep 17 00:00:00 2001 From: pfernie Date: Mon, 18 Oct 2021 14:58:47 -0400 Subject: [PATCH] Update `cookie_store` dependency (#1268) * Updated `cookie_store` dependency * Bump `cookie_store` version to `0.14.0` * Add documentation in `cookie` module to direct users to the new `reqwest_cookie_store` crate for more advanced scenarios. * update `cookie` dependency to `0.15` * Update for `cookie_store` `v0.14.1` * Replace usage of deprecated `cookie_store::CookieStore::get_request_cookies` for `cookie_store::CookieStore::get_request_values`. * Update `cookie_store` to `v0.15.0` The deprecation of `get_request_cookies` should have warranted a minor version bump. --- Cargo.toml | 4 ++-- src/cookie.rs | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2e86b81..bb2133d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,8 +119,8 @@ webpki-roots = { version = "0.21", optional = true } rustls-native-certs = { version = "0.5", optional = true } ## cookies -cookie_crate = { version = "0.14", package = "cookie", optional = true } -cookie_store = { version = "0.12", optional = true } +cookie_crate = { version = "0.15", package = "cookie", optional = true } +cookie_store = { version = "0.15", optional = true } time = { version = "0.2.11", optional = true } ## compression diff --git a/src/cookie.rs b/src/cookie.rs index 5bc7ee0..4363301 100644 --- a/src/cookie.rs +++ b/src/cookie.rs @@ -24,6 +24,10 @@ pub struct Cookie<'a>(cookie_crate::Cookie<'a>); /// This is the implementation used when simply calling `cookie_store(true)`. /// This type is exposed to allow creating one and filling it with some /// existing cookies more easily, before creating a `Client`. +/// +/// For more advanced scenarios, such as needing to serialize the store or +/// manipulate it between requests, you may refer to the +/// [reqwest_cookie_store crate](https://crates.io/crates/reqwest_cookie_store). #[derive(Debug, Default)] pub struct Jar(RwLock); @@ -88,7 +92,10 @@ impl<'a> Cookie<'a> { /// The cookie expiration time. pub fn expires(&self) -> Option { - self.0.expires().map(SystemTime::from) + match self.0.expires() { + Some(cookie_crate::Expiration::DateTime(offset)) => Some(SystemTime::from(offset)), + None | Some(cookie_crate::Expiration::Session) => None, + } } } @@ -170,8 +177,8 @@ impl CookieStore for Jar { .0 .read() .unwrap() - .get_request_cookies(url) - .map(|c| format!("{}={}", c.name(), c.value())) + .get_request_values(url) + .map(|(name, value)| format!("{}={}", name, value)) .collect::>() .join("; ");