Skip to content

Commit 3b86a7a

Browse files
colinmollenhourindexzero
authored andcommitted
Add 'proxyResponse' event so observer can modify response headers or abort response.
1 parent 4c130f5 commit 3b86a7a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: lib/node-http-proxy/http-proxy.js

+7
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
301301
}
302302
});
303303

304+
// Allow observer to modify headers or abort response
305+
try { req.emit('proxyResponse', req, res, response) }
306+
catch (ex) {
307+
errState = true;
308+
return;
309+
}
310+
304311
// Set the headers of the client response
305312
Object.keys(response.headers).forEach(function (key) {
306313
res.setHeader(key, response.headers[key]);

0 commit comments

Comments
 (0)