Update cookie crates (#946)
This commit is contained in:
@@ -99,9 +99,9 @@ tokio-rustls = { version = "0.13", optional = true }
|
|||||||
webpki-roots = { version = "0.19", optional = true }
|
webpki-roots = { version = "0.19", optional = true }
|
||||||
|
|
||||||
## cookies
|
## cookies
|
||||||
cookie_crate = { version = "0.12", package = "cookie", optional = true }
|
cookie_crate = { version = "0.14", package = "cookie", optional = true }
|
||||||
cookie_store = { version = "0.11", optional = true }
|
cookie_store = { version = "0.12", optional = true }
|
||||||
time = { version = "0.1.42", optional = true }
|
time = { version = "0.2.11", optional = true }
|
||||||
|
|
||||||
## compression
|
## compression
|
||||||
async-compression = { version = "0.3.0", default-features = false, features = ["stream"], optional = true }
|
async-compression = { version = "0.3.0", default-features = false, features = ["stream"], optional = true }
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
//! HTTP Cookies
|
//! HTTP Cookies
|
||||||
|
|
||||||
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use crate::header;
|
use crate::header;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
@@ -64,12 +66,12 @@ impl<'a> Cookie<'a> {
|
|||||||
pub fn max_age(&self) -> Option<std::time::Duration> {
|
pub fn max_age(&self) -> Option<std::time::Duration> {
|
||||||
self.0
|
self.0
|
||||||
.max_age()
|
.max_age()
|
||||||
.map(|d| std::time::Duration::new(d.num_seconds() as u64, 0))
|
.map(|d| d.try_into().expect("time::Duration into std::time::Duration"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The cookie expiration time.
|
/// The cookie expiration time.
|
||||||
pub fn expires(&self) -> Option<SystemTime> {
|
pub fn expires(&self) -> Option<SystemTime> {
|
||||||
self.0.expires().map(tm_to_systemtime)
|
self.0.expires().map(SystemTime::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,17 +100,6 @@ impl<'a> fmt::Debug for CookieStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a time::Tm time to SystemTime.
|
|
||||||
fn tm_to_systemtime(tm: time::Tm) -> SystemTime {
|
|
||||||
let seconds = tm.to_timespec().sec;
|
|
||||||
let duration = std::time::Duration::from_secs(seconds.abs() as u64);
|
|
||||||
if seconds > 0 {
|
|
||||||
SystemTime::UNIX_EPOCH + duration
|
|
||||||
} else {
|
|
||||||
SystemTime::UNIX_EPOCH - duration
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Error representing a parse failure of a 'Set-Cookie' header.
|
/// Error representing a parse failure of a 'Set-Cookie' header.
|
||||||
pub(crate) struct CookieParseError(cookie_crate::ParseError);
|
pub(crate) struct CookieParseError(cookie_crate::ParseError);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user