Skip to content

Commit

Permalink
feat: move adding of cookies
Browse files Browse the repository at this point in the history
Didn't fit well with merging of headers as the headers needed to be
re-borrowed anyway to get url
  • Loading branch information
c-git committed Aug 20, 2024
1 parent 56484a4 commit b8dc3ed
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/wasm/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,26 @@ impl Client {
entry.insert(value.clone());
}
}
}

pub(super) fn execute_request(
&self,
mut req: Request,
) -> impl Future<Output = crate::Result<Response>> {
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<Output = crate::Result<Response>> {
self.merge_headers(&mut req);
fetch(req, self.clone())
}
}
Expand Down

0 comments on commit b8dc3ed

Please sign in to comment.