fix serialization of cookies#2307
Conversation
karenetheridge
commented
Mar 20, 2026
- only one Cookie header is permitted; all cookies must be in a single string (see https://www.rfc-editor.org/rfc/rfc6265#section-5.4)
- the delimiter between individual cookie-pairs is "; ", not ", " (see https://www.rfc-editor.org/rfc/rfc6265#section-4.2.1)
|
Edit: I was mixing up |
eb31b96 to
51f3c06
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates Mojo::Headers cookie handling to comply with RFC 6265 by ensuring cookies serialize as a single Cookie header and use "; " as the cookie-pair delimiter.
Changes:
- Update
Mojo::Headersto join multipleCookievalues using"; "(instead of", "), including special handling into_string. - Adjust header value joining logic to treat
Cookiedifferently from other headers. - Add tests asserting correct
Cookieand general header serialization fromfrom_hash.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| t/mojo/headers.t | Adds assertions for to_string output and correct cookie flattening via from_hash/to_hash. |
| lib/Mojo/Headers.pm | Implements Cookie-specific joining in header() and to_string, and updates append() delimiter behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
289ad7a to
91de7bd
Compare
|
The header code is quite performance critical, any CPU cycles you can save will add up. |
91de7bd to
8dfe2a1
Compare
|
cleaned up, with unnecessary lc removed:
I also inlined a local variable so a string comparison is done only when needed, and created a local var in the monkey-patched method to avoid a runtime calculation. |
aae4553 to
7d9607f
Compare
- only one Cookie header is permitted; all cookies must be in a single string (see https://www.rfc-editor.org/rfc/rfc6265#section-5.4) - the delimiter between individual cookie-pairs is "; ", not ", " (see https://www.rfc-editor.org/rfc/rfc6265#section-4.2.1)
7d9607f to
7f964d9
Compare