Skip to content

Commit c0a796b

Browse files
committed
[fix] perf optimization so we have a precompiled regexp
1 parent 90d40d6 commit c0a796b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/http-proxy/common.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var common = exports,
22
url = require('url'),
33
extend = require('util')._extend;
44

5+
var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i;
56
/**
67
* Copies the right headers from `options` and `req` to
78
* `outgoing` which is then used to fire the proxied
@@ -53,7 +54,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
5354
if (!outgoing.agent) {
5455
outgoing.headers = outgoing.headers || {};
5556
if (typeof outgoing.headers.connection !== 'string'
56-
|| ! /(^|,)\s*upgrade\s*($|,)/i.test(outgoing.headers.connection)
57+
|| ! upgradeHeader.test(outgoing.headers.connection)
5758
) { outgoing.headers.connection = 'close'; }
5859
}
5960

0 commit comments

Comments
 (0)