From d6ea3a425c203695394eaba4ce8abd57f7809e98 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 14 Nov 2011 16:56:10 +0100 Subject: [PATCH] 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. --- lib/node-http-proxy.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node-http-proxy.js b/lib/node-http-proxy.js index 7b3d3be92..c0c85a536 100644 --- a/lib/node-http-proxy.js +++ b/lib/node-http-proxy.js @@ -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, @@ -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; }; }); @@ -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`