diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 2538a6e..8c0720b 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -301,6 +301,13 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { } }); + // Allow observer to modify headers or abort response + try { req.emit('proxyResponse', req, res, response) } + catch (ex) { + errState = true; + return; + } + // Set the headers of the client response Object.keys(response.headers).forEach(function (key) { res.setHeader(key, response.headers[key]);