From 2620f06e2db9a267945566f10837c4c2a5df753d Mon Sep 17 00:00:00 2001 From: indexzero Date: Mon, 18 Mar 2013 01:49:01 -0400 Subject: [PATCH] [fix breaking] Emit the `proxyResponse` event on the HttpProxy instance to reduce listener churn and reference counts. --- lib/node-http-proxy/http-proxy.js | 2 +- lib/node-http-proxy/routing-proxy.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 5ec206e14..6a08f2c7d 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -318,7 +318,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { }); // Allow observer to modify headers or abort response - try { req.emit('proxyResponse', req, res, response) } + try { self.emit('proxyResponse', req, res, response) } catch (ex) { errState = true; return; diff --git a/lib/node-http-proxy/routing-proxy.js b/lib/node-http-proxy/routing-proxy.js index 98c7a79d9..a8d0eade5 100644 --- a/lib/node-http-proxy/routing-proxy.js +++ b/lib/node-http-proxy/routing-proxy.js @@ -116,6 +116,7 @@ RoutingProxy.prototype.add = function (options) { 'start', 'forward', 'end', + 'proxyResponse', 'websocket:start', 'websocket:end', 'websocket:incoming',