From 0eb8d07e841ffe5c9fa38fe2b7c0914b62dc9413 Mon Sep 17 00:00:00 2001 From: kevinpoitra Date: Wed, 8 Jan 2020 02:20:26 -0600 Subject: [PATCH] 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 --- actix-http/src/cookie/builder.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/actix-http/src/cookie/builder.rs b/actix-http/src/cookie/builder.rs index 383c31b1c..c3820abf0 100644 --- a/actix-http/src/cookie/builder.rs +++ b/actix-http/src/cookie/builder.rs @@ -107,7 +107,9 @@ impl CookieBuilder { /// ``` #[inline] 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 }