diff options
author | Brian White <mscdex@mscdex.net> | 2016-08-23 13:49:21 -0400 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2016-08-26 10:17:34 -0400 |
commit | 1050594c867550f2417adae045160c6e39d70073 (patch) | |
tree | c930d7505880ecb378857df3010711bb46f65262 /lib/_http_common.js | |
parent | 7053922c1a76ac56ef245923ec171b01cd90d2f4 (diff) | |
download | node-new-1050594c867550f2417adae045160c6e39d70073.tar.gz |
http: fix connection upgrade checks
This commit fixes connection upgrade checks, specifically when headers
are passed as an array instead of a plain object to http.request()
Fixes: https://github.com/nodejs/node/issues/8235
PR-URL: https://github.com/nodejs/node/pull/8238
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/_http_common.js')
-rw-r--r-- | lib/_http_common.js | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/_http_common.js b/lib/_http_common.js index ad0389ba21..4640807731 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -80,17 +80,11 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method, parser.incoming.statusMessage = statusMessage; } - // The client made non-upgrade request, and server is just advertising - // supported protocols. - // - // See RFC7230 Section 6.7 - // - // NOTE: RegExp below matches `upgrade` in `Connection: abc, upgrade, def` - // header. - if (upgrade && - parser.outgoing !== null && - (parser.outgoing._headers.upgrade === undefined || - !/(^|\W)upgrade(\W|$)/i.test(parser.outgoing._headers.connection))) { + if (upgrade && parser.outgoing !== null && !parser.outgoing.upgrading) { + // The client made non-upgrade request, and server is just advertising + // supported protocols. + // + // See RFC7230 Section 6.7 upgrade = false; } |