diff --git a/lib/http-proxy/passes/web-incoming.js b/lib/http-proxy/passes/web-incoming.js index a2121e4fd..b74e61a7e 100644 --- a/lib/http-proxy/passes/web-incoming.js +++ b/lib/http-proxy/passes/web-incoming.js @@ -145,13 +145,13 @@ web_o = Object.keys(web_o).map(function(pass) { proxyReq.on('response', function(proxyRes) { if(server) { server.emit('proxyRes', proxyRes, req, res); } for(var i=0; i < web_o.length; i++) { - if(web_o[i](req, res, proxyRes, options)) { break; } + if(web_o[i](req, res, proxyRes, options)) { break; } } // Allow us to listen when the proxy has completed proxyRes.on('end', function () { - server.emit('end', req, res, proxyRes); - }) + server.emit('end', req, res, proxyRes); + }); proxyRes.pipe(res); });