diff options
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'", ); |