aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2019-07-15 22:25:26 +0200
committerRich Trott <rtrott@gmail.com>2019-07-18 20:58:54 -0700
commit2fd2dd75657af12a74e01a9a5e39e5f677ff3c88 (patch)
treec2de5fe2869ed08cc77ab8af36405ea2ce4aa4db /lib
parent1721034a40c5e7a0a334701dc36153adee3f27e5 (diff)
downloadandroid-node-v8-2fd2dd75657af12a74e01a9a5e39e5f677ff3c88.tar.gz
android-node-v8-2fd2dd75657af12a74e01a9a5e39e5f677ff3c88.tar.bz2
android-node-v8-2fd2dd75657af12a74e01a9a5e39e5f677ff3c88.zip
http: avoid extra listener
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'lib')
-rw-r--r--lib/_http_client.js7
1 files changed, 1 insertions, 6 deletions
diff --git a/lib/_http_client.js b/lib/_http_client.js
index cd15585e52..14d9e59f63 100644
--- a/lib/_http_client.js
+++ b/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
@@ -576,12 +572,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')