Fix headers.entries/values/forEach handling of setCookie #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It looks like the
headers.entries
/headers.values
/headers.forEach
logic we inherited when we forked isn't quite spec compliant when it comes to theSet-Cookie
header. Our current implementation blindly returnsthis.get(headerName)
in these iterators which concatenates multiple values, butSet-Cookie
is special and should instead treat each value as a standalone entry (internally via looping overgetAll
).Notice how in these examples, the custom header values are combined and comma-delimited, but
Set-Cookie
is not.Here's this behavior in Chrome:
And in node v18:
Also, FWIW, there's also a new
headers.getSetCookie
method which I think was added to help alleviate some of the confusion - but that's not available until node 19 so it didn't feel right to add that and start relying on it since we'd still be incompatible with node 18Response
instances.Closes remix-run/remix#4354
Relates to remix-run/remix#7150