diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2018-04-18 16:39:27 +0200 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-04-22 07:51:43 +0200 |
commit | e5f53206dd6559fecab3235aa620ef146c536f64 (patch) | |
tree | d1ab33af4b143443aa0671eed58b0b8905adeb88 /lib | |
parent | 54caeae38a66841b7f7119649dc78ce55c8a7c52 (diff) | |
download | android-node-v8-e5f53206dd6559fecab3235aa620ef146c536f64.tar.gz android-node-v8-e5f53206dd6559fecab3235aa620ef146c536f64.tar.bz2 android-node-v8-e5f53206dd6559fecab3235aa620ef146c536f64.zip |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_http_outgoing.js | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 8406c9cd8b..770e555d1e 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -52,7 +52,7 @@ const { utcDate } = internalHttp; 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; // 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); } -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) { if (field.length < 4 || field.length > 17) return; @@ -453,7 +439,10 @@ function matchHeader(self, state, field, value) { switch (field) { case 'connection': state.connection = true; - matchConnValue(self, state, value); + if (RE_CONN_CLOSE.test(value)) + self._last = true; + else + self.shouldKeepAlive = true; break; case 'transfer-encoding': state.te = true; |