From 0bcb38f2a51582d57da874653c717a29e2e79101 Mon Sep 17 00:00:00 2001 From: tsctx <91457664+tsctx@users.noreply.github.com> Date: Fri, 22 Dec 2023 22:31:18 +0900 Subject: [PATCH] perf: avoid toLowerCase call --- lib/fetch/index.js | 3 ++- lib/fetch/request.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/fetch/index.js b/lib/fetch/index.js index d64dd90596c..54dc6f35b18 100644 --- a/lib/fetch/index.js +++ b/lib/fetch/index.js @@ -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. diff --git a/lib/fetch/request.js b/lib/fetch/request.js index 85b8bb0df2f..f79e2bf46f0 100644 --- a/lib/fetch/request.js +++ b/lib/fetch/request.js @@ -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) } }