Fetch headers with same lowercase text are not merged properly when one header undefined
Categories
(DevTools :: Netmonitor, defect, P2)
Tracking
(Not tracked)
People
(Reporter: southpolesteve, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
|
299.33 KB,
image/png
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36
Steps to reproduce:
- Go to any webpage. In my case, I used firefox.com
- Open Dev tools
- Run this code: fetch("/", { headers: { Authorization: "foo", authorization: undefined }})
- Check the network requests tab
- See that the header for the request is listed as:
Authorization: undefined
Actual results:
Firefox did not combine these two headers. It only sent the header value with literal string "undefined"
Expected results:
I should see the authorization header sent as:
foo, undefined.
Chrome does this correctly. Screenshot attached showing the same request in both browsers
Comment 1•5 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Comment 2•5 years ago
|
||
Thanks for the report!
I can reproduce.
I see in chrome that
fetch("/", { headers: { Authorization: "foo", authorization: bar }}) shows Authorization: foo, bar but
fetch("/", { headers: { Authorization: "foo", Authorization: bar }}) shows Authorization: bar
In Firefox
fetch("/", { headers: { Authorization: "foo", authorization: bar }}) shows Authorization: bar and
fetch("/", { headers: { Authorization: "foo", Authorization: bar }}) also shows Authorization: bar
i'm wondering if the correct output should probably be
fetch("/", { headers: { Authorization: "foo", authorization: bar }}) should show Authorization: foo, bar
fetch("/", { headers: { Authorization: "foo", Authorization: bar }}) should show Authorization: foo, bar
Honza what do you think?
Updated•5 years ago
|
Updated•5 years ago
|
Comment 3•5 years ago
|
||
Comma-separated list is what the spec says, your proposal is correct:
https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list.
Comment 5•5 years ago
|
||
This seems to be a special case for "Authorization", other headers appear to work as expected.
It's not a display issue but the fact that fetch itself only sends the one header value for authorization.
I set up a tiny express app and it was receiving the same as the devtools netmonitor displays aka one authorization value.
fetch('/auth', {
headers: {
Accept: "*/*",
accept: "text/*",
'Accept-Language': "en-GB",
'accept-language': "en-US",
Authorization: 'foo',
authorization: undefined,
NotAuthorization: 'foo',
notauthorization: undefined
}
});
// Express headers (subset)
{
"accept": "*/*, text/*",
"accept-language": "en-GB, en-US",
"authorization": "undefined",
"notauthorization": "foo, undefined",
}
// Devtools displays headers (subset)
{
"accept": "*/*, text/*",
"accept-language": "en-GB, en-US",
"authorization": "undefined",
"notauthorization": "foo, undefined",
}
That's almost certainly as far as I can go but it might help someone else have a debug.
Description
•