-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Response Header.get() implementaion is wrong #911
Comments
Did you forgot to read the part of where it says: "Obsolete"? Used to return an array of all the values of a header within a Headers object with a given name; this method has now been deleted from the spec, and Headers.get() now returns all values of a given name instead of just the first one. |
I agree it's somewhat problematic. but we try to follow the spec |
But the join is still wrong. And it also says Headers.get() now returns all values of a given name |
Did MDN clearly say how to return it? no, there is no mentioning of array or string in that sentence.
The official spec mention it also:
https://fetch.spec.whatwg.org/#terminology-headers 0x2C === comma You can test out the browser behavior in this fiddle: https://jsfiddle.net/zL04o17w/ (same thing) |
This might be relevant for ya: whatwg/fetch#973 |
The Response Headers implementation is wrong. The Headers.get function converts arrays to strings. This neither conforms to Map nor the URLSearchParams class definitions. This is a problem when you try to parse the
set-cookie
headersExpected behavior, if applicable
Map implementation
The Headers class looks like a re-implementaion of URLSearchParams class, which is supported natively. You could save yourself a lot of code, and the implementation could match the standard.
As you can see
searchParams.get('set-cookie')
doesn't join the values but Headers.getAll doesn't exist in your implementation.Your Environment
From MDN
https://developer.mozilla.org/de/docs/Web/API/Headers
Obsolete methods
Headers.getAll()
Used to return an array of all the values of a header within a Headers object with a given name; this method has now been deleted from the spec, and Headers.get() now returns all values of a given name instead of just the first one
The text was updated successfully, but these errors were encountered: