[fix] merge #495, thanks @glasser

This commit is contained in:
yawnt 2013-11-07 19:13:09 +01:00
parent cde08fb2ee
commit d0862aff0c
2 changed files with 13 additions and 9 deletions

View File

@ -36,7 +36,7 @@ proxy.createProxyServer = proxy.createServer = function createProxyServer(option
* `options.target and `options.forward` cannot be
* both missing
* }
*/
*/
return new httpProxy.Server(options);
};

View File

@ -106,15 +106,11 @@ var passes = exports;
common.setupOutgoing(options.ssl || {}, options, req)
);
// Error Handler
proxyReq.on('error', function(err){
if (clb) {
clb(err);
} else {
server.emit('error', err, req, res);
}
});
proxyReq.on('error', onError);
proxyReq.on('upgrade', function(proxyRes, proxySocket, proxyHead) {
proxySocket.on('error', onError);
common.setupSocket(proxySocket);
if (proxyHead && proxyHead.length) proxySocket.unshift(proxyHead);
@ -126,7 +122,15 @@ var passes = exports;
proxySocket.pipe(socket).pipe(proxySocket);
});
proxyReq.end(); // XXX: CHECK IF THIS IS THIS CORRECT
return proxyReq.end(); // XXX: CHECK IF THIS IS THIS CORRECT
function onError(err) {
if (clb) {
clb(err);
} else {
server.emit('error', err, req, res);
}
}
}
] // <--