Skip to content

Commit

Permalink
don't add upgrade handler if a custom handler is passed in
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fjakobs authored and AvianFlu committed Nov 17, 2011
1 parent 152d258 commit d6ea3a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/node-http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var HttpProxy = exports.HttpProxy = require('./node-http-proxy/http-proxy'
exports.createServer = function () {
var args = Array.prototype.slice.call(arguments),
handlers = [],
callback,
options = {},
message,
handler,
Expand All @@ -77,7 +78,7 @@ exports.createServer = function () {
case 'string': host = arg; break;
case 'number': port = arg; break;
case 'object': options = arg || {}; break;
case 'function': handlers.push(arg); break;
case 'function': callback = arg; handlers.push(callback); break;
};
});

Expand Down Expand Up @@ -180,7 +181,7 @@ exports.createServer = function () {
proxy.close();
});

if (handlers.length <= 1) {
if (!callback) {
//
// If an explicit callback has not been supplied then
// automagically proxy the request using the `HttpProxy`
Expand Down

0 comments on commit d6ea3a4

Please sign in to comment.