From 43d5644048e4b8bab2beef56b4180ab8c92e9802 Mon Sep 17 00:00:00 2001 From: markthree <1801982702@qq.com> Date: Fri, 16 Jun 2023 00:27:21 +0800 Subject: [PATCH] refactor(ext/fetch): const for max header cache size (#19496) --- ext/fetch/20_headers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js index dcd3c95fc7..abf7433a31 100644 --- a/ext/fetch/20_headers.js +++ b/ext/fetch/20_headers.js @@ -105,6 +105,7 @@ function checkForInvalidValueChars(value) { } const HEADER_NAME_CACHE = new SafeMap(); +const HEADER_NAME_CACHE_SIZE_BOUNDARY = 4096; function checkHeaderNameForHttpTokenCodePoint(name) { if (MapPrototypeHas(HEADER_NAME_CACHE, name)) { return MapPrototypeGet(HEADER_NAME_CACHE, name); @@ -112,7 +113,7 @@ function checkHeaderNameForHttpTokenCodePoint(name) { const valid = RegExpPrototypeExec(HTTP_TOKEN_CODE_POINT_RE, name) !== null; - if (HEADER_NAME_CACHE.size > 4096) { + if (HEADER_NAME_CACHE.size > HEADER_NAME_CACHE_SIZE_BOUNDARY) { MapPrototypeClear(HEADER_NAME_CACHE); } MapPrototypeSet(HEADER_NAME_CACHE, name, valid);