From b8dc3ed16dee1011e8e060cae4448436d813bae3 Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:04:59 -0400 Subject: [PATCH] feat: move adding of cookies Didn't fit well with merging of headers as the headers needed to be re-borrowed anyway to get url --- src/wasm/client.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/wasm/client.rs b/src/wasm/client.rs index bbe4adf6c..0533b3162 100644 --- a/src/wasm/client.rs +++ b/src/wasm/client.rs @@ -151,24 +151,26 @@ impl Client { entry.insert(value.clone()); } } + } + + pub(super) fn execute_request( + &self, + mut req: Request, + ) -> impl Future> { + self.merge_headers(&mut req); // TODO Onè: We do not insert during polling like in non-wasm code. Test if this is covered by fetch. // Add cookies from the cookie store. #[cfg(feature = "cookies")] { if let Some(cookie_store) = self.config.cookie_store.as_ref() { - if headers.get(crate::header::COOKIE).is_none() { - add_cookie_header(&mut headers, &**cookie_store, &url); + if req.headers().get(crate::header::COOKIE).is_none() { + let url = req.url().clone(); // TODO Onè: Revisit and determine if clone is needed + add_cookie_header(req.headers_mut(), &**cookie_store, &url); } } } - } - pub(super) fn execute_request( - &self, - mut req: Request, - ) -> impl Future> { - self.merge_headers(&mut req); fetch(req, self.clone()) } }