From a2298b5ce51a00b926262cb4b010f414bf423dad Mon Sep 17 00:00:00 2001 From: Eran Hammer Date: Wed, 24 Apr 2013 17:06:01 -0700 Subject: [PATCH] Trying to solve #789 --- lib/response/stream.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/lib/response/stream.js b/lib/response/stream.js index 6e704debd..d3b5a4760 100755 --- a/lib/response/stream.js +++ b/lib/response/stream.js @@ -169,24 +169,13 @@ internals.Stream.prototype._transmit = function (request, callback) { isEnded = true; self._preview.end(); request.raw.res.end(); + self._stream.destroy && self._stream.destroy(); callback(); }; - request.raw.req.once('close', function () { - - end(); - }); - - this._stream.once('error', function () { - - request.raw.req.destroy(); - end(); - }); - - (encoder || this._stream).once('end', function () { - - end(); - }); + request.raw.req.once('close', end); + this._stream.once('error', end); + (encoder || this._stream).once('end', end); this._stream.pipe(this._preview); (encoder ? this._stream.pipe(encoder) : this._stream).pipe(request.raw.res, { end: false });