Updated to support error callback on proxy.web and start/proxyReq/end continue working.

This commit is contained in:
jleal52 2014-11-12 14:41:46 +00:00
parent 709b3e9656
commit 9ba8311343
2 changed files with 2 additions and 6 deletions

View File

@ -77,7 +77,7 @@ function createRightProxy(type) {
* refer to the connection socket
* pass(req, socket, options, head)
*/
if(passes[i](req, res, options, head, cbl ? false : this, cbl)) { // passes can return a truthy value to halt the loop
if(passes[i](req, res, options, head, this, cbl)) { // passes can return a truthy value to halt the loop
break;
}
}

View File

@ -92,9 +92,7 @@ web_o = Object.keys(web_o).map(function(pass) {
function stream(req, res, options, _, server, clb) {
// And we begin!
if (!clb) {
server.emit('start', req, res, options.target)
}
server.emit('start', req, res, options.target)
if(options.forward) {
// If forward enable, so just pipe the request
var forwardReq = (options.forward.protocol === 'https:' ? https : http).request(
@ -151,9 +149,7 @@ web_o = Object.keys(web_o).map(function(pass) {
// Allow us to listen when the proxy has completed
proxyRes.on('end', function () {
if (!clb) {
server.emit('end', req, res, proxyRes);
}
})
proxyRes.pipe(res);