Skip to content

Commit

Permalink
[fix] perf optimization so we have a precompiled regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrugzz committed Sep 17, 2014
1 parent 90d40d6 commit c0a796b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/http-proxy/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'; }
}

Expand Down

0 comments on commit c0a796b

Please sign in to comment.