ENH: added error events

This commit is contained in:
srossross 2013-09-15 15:20:51 -07:00
parent 29afab4488
commit 1b867a7f59
2 changed files with 15 additions and 0 deletions

View File

@ -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) {

View File

@ -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);