Skip to content

Commit

Permalink
Trying to solve hapijs#789
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer committed Apr 25, 2013
1 parent 46334ee commit a2298b5
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions lib/response/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit a2298b5

Please sign in to comment.