http: simplify connection: close search
Remove upgrade from the regular expression as it is no longer used and switch to using `.test()` instead of `.match()` as the value matched is irrelevant. PR-URL: https://github.com/nodejs/node/pull/20131 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
54caeae38a
commit
e5f53206dd
@ -52,7 +52,7 @@ const { utcDate } = internalHttp;
|
|||||||
|
|
||||||
const kIsCorked = Symbol('isCorked');
|
const kIsCorked = Symbol('isCorked');
|
||||||
|
|
||||||
var RE_CONN_VALUES = /(?:^|\W)close|upgrade(?:$|\W)/ig;
|
var RE_CONN_CLOSE = /(?:^|\W)close(?:$|\W)/i;
|
||||||
var RE_TE_CHUNKED = common.chunkExpression;
|
var RE_TE_CHUNKED = common.chunkExpression;
|
||||||
|
|
||||||
// isCookieField performs a case-insensitive comparison of a provided string
|
// isCookieField performs a case-insensitive comparison of a provided string
|
||||||
@ -432,20 +432,6 @@ function storeHeader(self, state, key, value, validate) {
|
|||||||
matchHeader(self, state, key, value);
|
matchHeader(self, state, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function matchConnValue(self, state, value) {
|
|
||||||
var sawClose = false;
|
|
||||||
var m = RE_CONN_VALUES.exec(value);
|
|
||||||
while (m) {
|
|
||||||
if (m[0].length === 5)
|
|
||||||
sawClose = true;
|
|
||||||
m = RE_CONN_VALUES.exec(value);
|
|
||||||
}
|
|
||||||
if (sawClose)
|
|
||||||
self._last = true;
|
|
||||||
else
|
|
||||||
self.shouldKeepAlive = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function matchHeader(self, state, field, value) {
|
function matchHeader(self, state, field, value) {
|
||||||
if (field.length < 4 || field.length > 17)
|
if (field.length < 4 || field.length > 17)
|
||||||
return;
|
return;
|
||||||
@ -453,7 +439,10 @@ function matchHeader(self, state, field, value) {
|
|||||||
switch (field) {
|
switch (field) {
|
||||||
case 'connection':
|
case 'connection':
|
||||||
state.connection = true;
|
state.connection = true;
|
||||||
matchConnValue(self, state, value);
|
if (RE_CONN_CLOSE.test(value))
|
||||||
|
self._last = true;
|
||||||
|
else
|
||||||
|
self.shouldKeepAlive = true;
|
||||||
break;
|
break;
|
||||||
case 'transfer-encoding':
|
case 'transfer-encoding':
|
||||||
state.te = true;
|
state.te = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user