From c0a796b3e31de4f22eef00d93164e7238d9aa3ba Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Wed, 17 Sep 2014 07:53:18 -0400 Subject: [PATCH] [fix] perf optimization so we have a precompiled regexp --- lib/http-proxy/common.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index 52cb0ff7c..7c374b0c8 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'; } }