mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[fix] perf optimization so we have a precompiled regexp
This commit is contained in:
parent
90d40d6a6a
commit
c0a796b3e3
@ -2,6 +2,7 @@ var common = exports,
|
|||||||
url = require('url'),
|
url = require('url'),
|
||||||
extend = require('util')._extend;
|
extend = require('util')._extend;
|
||||||
|
|
||||||
|
var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i;
|
||||||
/**
|
/**
|
||||||
* Copies the right headers from `options` and `req` to
|
* Copies the right headers from `options` and `req` to
|
||||||
* `outgoing` which is then used to fire the proxied
|
* `outgoing` which is then used to fire the proxied
|
||||||
@ -53,7 +54,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'
|
||||||
|| ! /(^|,)\s*upgrade\s*($|,)/i.test(outgoing.headers.connection)
|
|| ! upgradeHeader.test(outgoing.headers.connection)
|
||||||
) { outgoing.headers.connection = 'close'; }
|
) { outgoing.headers.connection = 'close'; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user