Skip to content

Commit

Permalink
Update cookie_store dependency (seanmonstar#1268)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
pfernie authored Oct 18, 2021
1 parent bd4e0c6 commit 1365698
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions src/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<cookie_store::CookieStore>);

Expand Down Expand Up @@ -88,7 +92,10 @@ impl<'a> Cookie<'a> {

/// The cookie expiration time.
pub fn expires(&self) -> Option<SystemTime> {
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,
}
}
}

Expand Down Expand Up @@ -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::<Vec<_>>()
.join("; ");

Expand Down

0 comments on commit 1365698

Please sign in to comment.