Truncate any nanoseconds from a supplied `Duration` within `Cookie::set_max_age` to ensure two Cookies with the same amount whole seconds equate to one another

This commit is contained in:
kevinpoitra 2020-01-08 02:20:26 -06:00
parent 7e569bccf6
commit 0eb8d07e84
1 changed files with 3 additions and 1 deletions

View File

@ -107,7 +107,9 @@ impl CookieBuilder {
/// ``` /// ```
#[inline] #[inline]
pub fn max_age_time(mut self, value: Duration) -> CookieBuilder { pub fn max_age_time(mut self, value: Duration) -> CookieBuilder {
self.cookie.set_max_age(value); // Truncate any nanoseconds from the Duration, as they aren't represented within `Max-Age`
// and would cause two otherwise identical `Cookie` instances to not be equivalent to one another.
self.cookie.set_max_age(Duration::seconds(value.whole_seconds()));
self self
} }