Skip to content
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

perf: avoid toLowerCase call #2537

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2152,7 +2152,8 @@ async function httpNetworkFetch (
} else {
const keys = Object.keys(rawHeaders)
for (let i = 0; i < keys.length; ++i) {
headersList.append(keys[i], rawHeaders[keys[i]])
// The header names are already in lowercase.
headersList.append(keys[i], rawHeaders[keys[i]], true)
}
// For H2, The header names are already in lowercase,
// so we can avoid the `HeadersList#get` call here.
Expand Down
2 changes: 1 addition & 1 deletion lib/fetch/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ class Request {
// 3, If Content-Type is non-null and this’s headers’s header list does
// not contain `Content-Type`, then append `Content-Type`/Content-Type to
// this’s headers.
if (contentType && !this[kHeaders][kHeadersList].contains('content-type')) {
if (contentType && !this[kHeaders][kHeadersList].contains('content-type', true)) {
this[kHeaders].append('content-type', contentType)
}
}
Expand Down
Loading