Skip to content

Commit

Permalink
perf: avoid toLowerCase call (nodejs#2537)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx authored and crysmags committed Feb 27, 2024
1 parent d0d37cc commit cd72842
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
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

0 comments on commit cd72842

Please sign in to comment.