diff options
author | Pavel Hrách <pavel@hrach.email> | 2021-07-24 04:14:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-24 12:14:03 +1000 |
commit | 74c7559d2029539eb6ab7459c06061c00b3e0c1a (patch) | |
tree | d8a25878dd62c447442e416c4eb77e20f020793c /extensions/http/01_http.js | |
parent | 3e08b6ae89f9d29d5249345697fca6f86284bc3d (diff) |
fix(http): support multiple options in connection header for websocket (#11505)
Fixes #11494
Diffstat (limited to 'extensions/http/01_http.js')
-rw-r--r-- | extensions/http/01_http.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/extensions/http/01_http.js b/extensions/http/01_http.js index e0f221ce0..2b0d8cd2c 100644 --- a/extensions/http/01_http.js +++ b/extensions/http/01_http.js @@ -22,8 +22,10 @@ const { ArrayPrototypeIncludes, ArrayPrototypePush, + ArrayPrototypeSome, Promise, StringPrototypeIncludes, + StringPrototypeToLowerCase, StringPrototypeSplit, Symbol, SymbolAsyncIterator, @@ -321,7 +323,13 @@ ); } - if (request.headers.get("connection")?.toLowerCase() !== "upgrade") { + const connection = request.headers.get("connection"); + const connectionHasUpgradeOption = connection !== null && + ArrayPrototypeSome( + StringPrototypeSplit(connection, /\s*,\s*/), + (option) => StringPrototypeToLowerCase(option) === "upgrade", + ); + if (!connectionHasUpgradeOption) { throw new TypeError( "Invalid Header: 'connection' header must be 'Upgrade'", ); |