use regex to check for upgrade header

in websocket connections
This commit is contained in:
MinRK 2014-09-16 11:14:56 -07:00
parent 51eeebef68
commit 65a21bce6d

View File

@ -53,8 +53,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
if (!outgoing.agent) { if (!outgoing.agent) {
outgoing.headers = outgoing.headers || {}; outgoing.headers = outgoing.headers || {};
if (typeof outgoing.headers.connection !== 'string' if (typeof outgoing.headers.connection !== 'string'
|| !outgoing.headers.connection.toLowerCase().split(',').some( || ! /(^|,)\s*upgrade\s*($|,)/i.test(outgoing.headers.connection)
function (s) { if (s.trim() === 'upgrade') { return true; } })
) { outgoing.headers.connection = 'close'; } ) { outgoing.headers.connection = 'close'; }
} }