From 64b4fc81cad24dfb9a6b7dfdbfe41f5ee898ad82 Mon Sep 17 00:00:00 2001 From: goingforstudying-ctrl Date: Sat, 23 May 2026 09:18:40 +0000 Subject: [PATCH 1/2] fix: send all matching cookies instead of only the last one When multiple cookies match a URL, the previous code used which overwrote the Cookie header on each iteration, causing only the last matching cookie to be sent. This fix collects all matching cookie name=value pairs and joins them with '; ' (per RFC 6265) into a single Cookie header value. Fixes #479 --- src/session.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/session.rs b/src/session.rs index 266a5fc1..31c0d863 100644 --- a/src/session.rs +++ b/src/session.rs @@ -145,13 +145,18 @@ impl Session { // URL not in cache, we retrieve the file let mut headers = HeaderMap::new(); if self.cookies.is_some() && !self.cookies.as_ref().unwrap().is_empty() { + let mut cookie_values: Vec = Vec::new(); for cookie in self.cookies.as_ref().unwrap() { if !cookie.is_expired() && cookie.matches_url(url.as_str()) { - let cookie_header_value: String = cookie.name.clone() + "=" + &cookie.value; - headers - .insert(COOKIE, HeaderValue::from_str(&cookie_header_value).unwrap()); + cookie_values.push(cookie.name.clone() + "=" + &cookie.value); } } + if !cookie_values.is_empty() { + headers.insert( + COOKIE, + HeaderValue::from_str(&cookie_values.join("; ")).unwrap(), + ); + } } // Add referer header for page resource requests if ["https", "http"].contains(&parent_url.scheme()) && parent_url != url { From daddc3cee0ede525f943d50990c2a2ae1071486d Mon Sep 17 00:00:00 2001 From: goingforstudying-ctrl Date: Mon, 25 May 2026 18:03:37 +0000 Subject: [PATCH 2/2] style: run cargo fmt --- src/html.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/html.rs b/src/html.rs index beb72e7c..91a488d8 100644 --- a/src/html.rs +++ b/src/html.rs @@ -1022,11 +1022,7 @@ pub fn walk(session: &mut Session, document_url: &Url, node: &Handle) { set_node_attr(node, attr_name, None); } else if use_attr_href_value.clone().starts_with('#') { // Relative symbol that resolves to its own URL; keep as-is. - set_node_attr( - node, - attr_name, - Some(use_attr_href_value), - ); + set_node_attr(node, attr_name, Some(use_attr_href_value)); } else { let image_asset_url: Url = resolve_url(document_url, &use_attr_href_value);