diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index 52cb0ff..7c374b0 100644 --- a/lib/http-proxy/common.js +++ b/lib/http-proxy/common.js @@ -2,6 +2,7 @@ var common = exports, url = require('url'), extend = require('util')._extend; +var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i; /** * Copies the right headers from `options` and `req` to * `outgoing` which is then used to fire the proxied @@ -53,7 +54,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) { if (!outgoing.agent) { outgoing.headers = outgoing.headers || {}; if (typeof outgoing.headers.connection !== 'string' - || ! /(^|,)\s*upgrade\s*($|,)/i.test(outgoing.headers.connection) + || ! upgradeHeader.test(outgoing.headers.connection) ) { outgoing.headers.connection = 'close'; } }