1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -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 GitHub
parent 0c50c39c35
commit 43d5644048
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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