Skip to content

Commit d6ea3a4

Browse files
fjakobsAvianFlu
authored andcommitted
don't add upgrade handler if a custom handler is passed in
if a callback but no static proxy is defined and no routes are provided then handlers.length is 1. However the upgrade event is still automagically attached in spite of having an explicit callback.
1 parent 152d258 commit d6ea3a4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: lib/node-http-proxy.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ var HttpProxy = exports.HttpProxy = require('./node-http-proxy/http-proxy'
5757
exports.createServer = function () {
5858
var args = Array.prototype.slice.call(arguments),
5959
handlers = [],
60+
callback,
6061
options = {},
6162
message,
6263
handler,
@@ -77,7 +78,7 @@ exports.createServer = function () {
7778
case 'string': host = arg; break;
7879
case 'number': port = arg; break;
7980
case 'object': options = arg || {}; break;
80-
case 'function': handlers.push(arg); break;
81+
case 'function': callback = arg; handlers.push(callback); break;
8182
};
8283
});
8384

@@ -180,7 +181,7 @@ exports.createServer = function () {
180181
proxy.close();
181182
});
182183

183-
if (handlers.length <= 1) {
184+
if (!callback) {
184185
//
185186
// If an explicit callback has not been supplied then
186187
// automagically proxy the request using the `HttpProxy`

0 commit comments

Comments
 (0)