From 8eb6780f8705caff13a5375446539b0621d497d7 Mon Sep 17 00:00:00 2001 From: vinodsr Date: Fri, 31 May 2013 07:02:32 +0530 Subject: [PATCH] added option for eventlistenerCount(max) --- lib/node-http-proxy/http-proxy.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 6590ed9..92541ba 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -103,6 +103,9 @@ var HttpProxy = exports.HttpProxy = function (options) { ? this.enable.xforward : true; + // if event listener is set then use it else unlimited. + this.eventListenerCount = typeof options.eventListenerCount === 'number'? options.eventListenerCount : 0 ; + // // Setup additional options for WebSocket proxying. When forcing // the WebSocket handshake to change the `sec-websocket-location` @@ -371,10 +374,9 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { res.on('drain', ondrain); }); - // allow unlimited listeners ... - reverseProxy.setMaxListeners(0); - + reverseProxy.setMaxListeners(this.eventListenerCount); + // // Handle 'error' events from the `reverseProxy`. Setup timeout override if needed //