From 4c130f5dac5f2cfbfc2618446b86244aff4cb04f Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Sat, 29 Dec 2012 01:23:46 -0500 Subject: [PATCH] Allow event observers to access upstream response headers and data. --- lib/node-http-proxy/http-proxy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 8df6174..2538a6e 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -297,7 +297,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { catch (ex) { console.error("res.end error: %s", ex.message) } // Emit the `end` event now that we have completed proxying - self.emit('end', req, res); + self.emit('end', req, res, response); } }); @@ -318,6 +318,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { response.pause(); } } + self.emit('data', chunk, req); } response.on('data', ondata);