From 58445be4ff0d143348e85da708fe5801c7ea9dd5 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Tue, 4 Jul 2017 14:51:00 -0700 Subject: [PATCH] Add 'LocalRequest' cookies as original. --- lib/src/http/cookies.rs | 7 +++++++ lib/src/local/request.rs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/src/http/cookies.rs b/lib/src/http/cookies.rs index 9e6242af..523ca631 100644 --- a/lib/src/http/cookies.rs +++ b/lib/src/http/cookies.rs @@ -132,6 +132,13 @@ impl<'a> Cookies<'a> { Cookie::parse_encoded(cookie_str).map(|c| c.into_owned()).ok() } + /// Adds an original `cookie` to this collection. + pub(crate) fn add_original(&mut self, cookie: Cookie<'static>) { + if let Cookies::Jarred(ref mut jar, _) = *self { + jar.add_original(cookie) + } + } + /// Returns a reference to the `Cookie` inside this container with the name /// `name`. If no such cookie exists, returns `None`. /// diff --git a/lib/src/local/request.rs b/lib/src/local/request.rs index 938e5ef6..f708f2d2 100644 --- a/lib/src/local/request.rs +++ b/lib/src/local/request.rs @@ -185,7 +185,7 @@ impl<'c> LocalRequest<'c> { /// ``` #[inline] pub fn cookie(self, cookie: Cookie<'static>) -> Self { - self.request.cookies().add(cookie); + self.request.cookies().add_original(cookie); self }