diff --git a/lib/http-proxy/index.js b/lib/http-proxy/index.js index 8767dfb..ba04e0d 100644 --- a/lib/http-proxy/index.js +++ b/lib/http-proxy/index.js @@ -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; } } diff --git a/lib/http-proxy/passes/web-incoming.js b/lib/http-proxy/passes/web-incoming.js index c7805a4..572c11a 100644 --- a/lib/http-proxy/passes/web-incoming.js +++ b/lib/http-proxy/passes/web-incoming.js @@ -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);