diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index a391102..8887972 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -266,7 +266,12 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { // already been called and the 'error' event listener // removed. // + var ended = false + response.on('close', function () { + if(!ended) response.emit('end') + }) response.on('end', function () { + ended = true if (!errState) { reverseProxy.removeListener('error', proxyError);