Skip to content

fix: send all matching cookies instead of only the last one#492

Merged
snshn merged 2 commits into
Y2Z:masterfrom
goingforstudying-ctrl:fix/cookie-multiple-values
May 25, 2026
Merged

fix: send all matching cookies instead of only the last one#492
snshn merged 2 commits into
Y2Z:masterfrom
goingforstudying-ctrl:fix/cookie-multiple-values

Conversation

@goingforstudying-ctrl
Copy link
Copy Markdown

What

Fixes a bug where only the last matching cookie was sent when multiple cookies matched a URL.

Why

When using a cookies file with multiple cookies for the same domain, only one cookie would be sent in the HTTP request. This breaks websites that require multiple cookies for authentication or session management.

The root cause was using inside a loop, which overwrote the Cookie header on each iteration.

How

  • Collect all matching cookie name=value pairs into a Vec
  • Join them with (per RFC 6265)
  • Insert the combined value as a single Cookie header

Testing

Fixes #479

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 Y2Z#479
@goingforstudying-ctrl
Copy link
Copy Markdown
Author

Hi @snshn — this fixes the cookie handling bug from #479 where only the last matching cookie was sent. Ready for review whenever you have a moment.

@goingforstudying-ctrl
Copy link
Copy Markdown
Author

CI is green, no conflicts. Fix sends all matching cookies instead of only the last one. Ready for review.

@snshn
Copy link
Copy Markdown
Member

snshn commented May 25, 2026

Hello dear sir!

Thank you very much for this patch! Good catch, and I'm glad to be able to merge it in for the next release.

It seems like the pipeline fails to validate the code format, could you please do make lint and/or make format to make it nice and tidy?

@snshn snshn self-requested a review May 25, 2026 16:17
@goingforstudying-ctrl
Copy link
Copy Markdown
Author

Thanks for the quick review! Ran cargo fmt and pushed — should be clean now. Let me know if anything else needs tweaking.

@snshn
Copy link
Copy Markdown
Member

snshn commented May 25, 2026

No-no, this is great, I'm gonna go ahead and merge this in.

If there're any other issues like escaping certain characters, we can do it separately, in another PR.

Thanks again!

@snshn snshn merged commit a6fc8d0 into Y2Z:master May 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple cookies for the same domain don't appear to get sent

2 participants