summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarkthree <1801982702@qq.com>2023-06-16 00:27:21 +0800
committerGitHub <noreply@github.com>2023-06-15 18:27:21 +0200
commit43d5644048e4b8bab2beef56b4180ab8c92e9802 (patch)
tree5127153c1a98d7017d00df5b4e5cd868a447e41e
parent0c50c39c35f1c92bbb96bc3e101e2c446256cb7b (diff)
refactor(ext/fetch): const for max header cache size (#19496)
-rw-r--r--ext/fetch/20_headers.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js
index dcd3c95fc..abf7433a3 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);