-
-
Notifications
You must be signed in to change notification settings - Fork 613
fix: change set-cookie header to always be an array #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
For compatibility with the Node.js API `set-cookie` header, if present, has to always be an array, even when there is only one value in it.
I think the original thought here was that undici considers as little user land edge cases as possible and assumes what is provided is correct (or at least correct in terms of the protocol) and leave these kind of compat logic to higher level libraries, e.g. we don't check that That being said I'm not opposed to including these kind of things. @mcollina WDYT? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately lgtm
I'm having some second thoughts on this. It feels a bit like a rabbit hole. If we do this should we implement all the other weird Node behaviors as well? Where do we stop? Would like to think about this a bit more. Not sure adding edge cases is a good idea. |
59cc0c9
to
a0af7ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right direction. If we go down this path we'll end up back where we started with Node's existing "strange" behaviors.
b847d04
to
4ea0f80
Compare
Anyone disagreeing to my objection or can we close this? |
no, not really |
@mcollina @ronag I would like to clarify, to explain my idea for this PR. |
@belochub Thanks for the description. I think this should be resolved in
Depends... for most headers it's more convenient to have it as a string. |
@ronag I agree, that for most headers this is better, thus the current behavior of this package, combining duplicate headers into an array instead of a string, might be an inconvenience for some users. |
For compatibility with the Node.js API
set-cookie
header, if present,has to always be an array, even when there is only one value in it.
For reference, see https://nodejs.org/api/http.html#http_message_headers
There is also a possible compatibility problem with the way duplicate headers are handled right now since you always collect all duplicates to an array, but Node.js discards duplicates of some of the headers and joins the duplicate values with ', ' or '; ' for others. This can be fixed separately if you want full compatibility with Node.js, but for now, I only wanted to handle one issue that I discovered while using this package.