mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Add 'proxyResponse' event so observer can modify response headers or abort response.
This commit is contained in:
parent
4c130f5dac
commit
3b86a7aae3
@ -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]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user