Skip to content

Commit

Permalink
added option for eventlistenerCount(max)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinodsr authored and indexzero committed Dec 27, 2013
1 parent 1333c0c commit 8eb6780
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/node-http-proxy/http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
//
Expand Down

0 comments on commit 8eb6780

Please sign in to comment.