Skip to content
Permalink
Browse files

http: avoid extra listener

PR-URL: #28705
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
  • Loading branch information...
ronag authored and targos committed Jul 15, 2019
1 parent 1ce2b5e commit ed8504388e72152330b38af40cb2700f852e33f4
Showing with 1 addition and 6 deletions.
  1. +1 −6 lib/_http_client.js
@@ -320,10 +320,6 @@ ClientRequest.prototype.abort = function abort() {
// If we're aborting, we don't care about any more response data.
if (this.res) {
this.res._dump();
} else {
this.once('response', (res) => {
res._dump();
});
}

// In the event that we don't have a socket, we will pop out of
@@ -572,12 +568,11 @@ function parserOnIncomingClient(res, shouldKeepAlive) {
// Add our listener first, so that we guarantee socket cleanup
res.on('end', responseOnEnd);
req.on('prefinish', requestOnPrefinish);
const handled = req.emit('response', res);

// If the user did not listen for the 'response' event, then they
// can't possibly read the data, so we ._dump() it into the void
// so that the socket doesn't hang there in a paused state.
if (!handled)
if (req.aborted || !req.emit('response', res))
res._dump();

if (method === 'HEAD')

0 comments on commit ed85043

Please sign in to comment.
You can’t perform that action at this time.