mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
ENH: added error events
This commit is contained in:
parent
29afab4488
commit
1b867a7f59
@ -102,6 +102,14 @@ function stream(req, res, options) {
|
||||
common.setupOutgoing(options.ssl || {}, options, req)
|
||||
);
|
||||
|
||||
proxyReq.on('error', function(err){
|
||||
var ev = 'caronte:outgoing:web:';
|
||||
if (options.ee.listeners(ev + 'error').length == 0){
|
||||
throw err;
|
||||
}
|
||||
options.ee.emit(ev + 'error', err, req, res);
|
||||
});
|
||||
|
||||
req.pipe(proxyReq);
|
||||
|
||||
proxyReq.on('response', function(proxyRes) {
|
||||
|
||||
@ -78,6 +78,13 @@ function stream(req, socket, options, head) {
|
||||
var proxyReq = (~['https:', 'wss:'].indexOf(options.target.protocol) ? https : http).request(
|
||||
common.setupOutgoing(options.ssl || {}, options, req)
|
||||
);
|
||||
proxyReq.on('error', function(err){
|
||||
var ev = 'caronte:outgoing:ws:';
|
||||
if (options.ee.listeners(ev + 'error').length == 0){
|
||||
throw err;
|
||||
}
|
||||
options.ee.emit(ev + 'error', err, req, res);
|
||||
});
|
||||
|
||||
proxyReq.on('upgrade', function(proxyRes, proxySocket, proxyHead) {
|
||||
common.setupSocket(proxySocket);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user