1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-07 06:46:59 -05:00

refactor(ext/fetch): const for max header cache size (#19496)

This commit is contained in:
markthree 2023-06-16 00:27:21 +08:00 committed by Bartek Iwańczuk
parent 8e720515d3
commit c9c3a2bf13
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750

View file

@ -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);