From 1422997eeaf9cdf799670912c1ca12486a2abfe3 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Sat, 17 Aug 2024 11:58:12 +0200 Subject: [PATCH] perf: set isLowerCase param on all calls of HeadersList.append (#3468) --- lib/web/cookies/index.js | 2 +- lib/web/fetch/index.js | 2 +- lib/web/fetch/request.js | 2 +- lib/web/websocket/connection.js | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/web/cookies/index.js b/lib/web/cookies/index.js index 323aa9ee6fb..88634dd01e3 100644 --- a/lib/web/cookies/index.js +++ b/lib/web/cookies/index.js @@ -102,7 +102,7 @@ function setCookie (headers, cookie) { const str = stringify(cookie) if (str) { - headers.append('Set-Cookie', str) + headers.append('set-cookie', str, true) } } diff --git a/lib/web/fetch/index.js b/lib/web/fetch/index.js index efc0334f74f..f9b3629c07b 100644 --- a/lib/web/fetch/index.js +++ b/lib/web/fetch/index.js @@ -1460,7 +1460,7 @@ async function httpNetworkOrCacheFetch ( // user agents should append `User-Agent`/default `User-Agent` value to // httpRequest’s header list. if (!httpRequest.headersList.contains('user-agent', true)) { - httpRequest.headersList.append('user-agent', defaultUserAgent) + httpRequest.headersList.append('user-agent', defaultUserAgent, true) } // 15. If httpRequest’s cache mode is "default" and httpRequest’s header diff --git a/lib/web/fetch/request.js b/lib/web/fetch/request.js index bcd86bc1e96..ca0153922af 100644 --- a/lib/web/fetch/request.js +++ b/lib/web/fetch/request.js @@ -520,7 +520,7 @@ class Request { // not contain `Content-Type`, then append `Content-Type`/Content-Type to // this’s headers. if (contentType && !getHeadersList(this[kHeaders]).contains('content-type', true)) { - this[kHeaders].append('content-type', contentType) + this[kHeaders].append('content-type', contentType, true) } } diff --git a/lib/web/websocket/connection.js b/lib/web/websocket/connection.js index d2baa9b5aab..0356d51d9c7 100644 --- a/lib/web/websocket/connection.js +++ b/lib/web/websocket/connection.js @@ -22,7 +22,7 @@ try { * @param {URL} url * @param {string|string[]} protocols * @param {import('./websocket').Handler} handler - * @param {Partial} options + * @param {Partial} options */ function establishWebSocketConnection (url, protocols, client, handler, options) { // 1. Let requestURL be a copy of url, with its scheme set to "http", if url’s @@ -65,17 +65,17 @@ function establishWebSocketConnection (url, protocols, client, handler, options) // 6. Append (`Sec-WebSocket-Key`, keyValue) to request’s // header list. - request.headersList.append('sec-websocket-key', keyValue) + request.headersList.append('sec-websocket-key', keyValue, true) // 7. Append (`Sec-WebSocket-Version`, `13`) to request’s // header list. - request.headersList.append('sec-websocket-version', '13') + request.headersList.append('sec-websocket-version', '13', true) // 8. For each protocol in protocols, combine // (`Sec-WebSocket-Protocol`, protocol) in request’s header // list. for (const protocol of protocols) { - request.headersList.append('sec-websocket-protocol', protocol) + request.headersList.append('sec-websocket-protocol', protocol, true) } // 9. Let permessageDeflate be a user-agent defined @@ -85,7 +85,7 @@ function establishWebSocketConnection (url, protocols, client, handler, options) // 10. Append (`Sec-WebSocket-Extensions`, permessageDeflate) to // request’s header list. - request.headersList.append('sec-websocket-extensions', permessageDeflate) + request.headersList.append('sec-websocket-extensions', permessageDeflate, true) // 11. Fetch request with useParallelQueue set to true, and // processResponse given response being these steps: