Commit d6ea3a42 authored by Fabian Jakobs's avatar Fabian Jakobs Committed by Charlie McConnell

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.
parent 152d258e
......@@ -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`
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment