-
-
Notifications
You must be signed in to change notification settings - Fork 665
fix: correctly handle multi-value headers in fetch when rawHeaders
contains array
#4390
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
base: main
Are you sure you want to change the base?
Conversation
4c50452
to
6ebaf87
Compare
rawHeaders
contains array
I've pushed a different fix as discussed in #4390 (comment). Please take a look, thanks! |
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.
code wise, lgtm; but defer to @KhafraDev
@@ -2110,7 +2110,15 @@ async function httpNetworkFetch ( | |||
const headersList = new HeadersList() | |||
|
|||
for (let i = 0; i < rawHeaders.length; i += 2) { | |||
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i]), rawHeaders[i + 1].toString('latin1'), true) | |||
const nameStr = bufferToLowerCasedHeaderName(rawHeaders[i]) |
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.
As this only breaks given an interceptor, I'd prefer that we fix it within undici
's rather than fetch
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.
My idea is that fetch should properly support arrays of header values in rawHeaders
, if such case is valid.
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.
Sure, but I'd prefer to cross check with the spec to see what it has to say regarding duplicated headers, if the implementation already aligns, most likely is an undici
issue.
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.
IIUC, RFC 7230 Section 3.2.2 means that:
- A sender must not send multiple headers with the same name unless it is
Set-Cookie
, - A receiver may combine values of multiple headers with the same name into a comma-separated list, except for
Set-Cookie
.
I'd say it is fine to have them separated in Undici/interceptor APIs, and only join them in fetch.
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.
You refer to RFC7230 but not the fetch spec
Gentle ping. May I have some reviews again? The latest change only touches |
This relates to...
#4389
Changes
In
httpNetworkFetch->dispatch->onHeaders
, append multi-value header values one by one and letHeadersList
handle concatenation.Features
N/A
Bug Fixes
#4389
Breaking Changes and Deprecations
N/A
Status