Skip to content

Commit

Permalink
Add 'proxyResponse' event so observer can modify response headers or …
Browse files Browse the repository at this point in the history
…abort response.
  • Loading branch information
colinmollenhour authored and indexzero committed Mar 9, 2013
1 parent 4c130f5 commit 3b86a7a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/node-http-proxy/http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 3b86a7a

Please sign in to comment.