diff options
author | Luigi Pinca <luigipinca@gmail.com> | 2017-11-03 18:13:48 +0100 |
---|---|---|
committer | Luigi Pinca <luigipinca@gmail.com> | 2017-11-06 22:15:48 +0100 |
commit | f60c692499c488d4ab59b67b258eea88dc826287 (patch) | |
tree | eec08169bc525bcb83ff12467c09ec61748c2f76 /lib/_http_client.js | |
parent | fb31e074503145302acaaec49bbf779fdf067d83 (diff) | |
download | android-node-v8-f60c692499c488d4ab59b67b258eea88dc826287.tar.gz android-node-v8-f60c692499c488d4ab59b67b258eea88dc826287.tar.bz2 android-node-v8-f60c692499c488d4ab59b67b258eea88dc826287.zip |
http: use 'connect' event only if socket is connecting
Fixes a bug that prevented `ClientRequest.prototype.setTimeout()` from
working properly when the socket was reused for multiple requests.
Fixes: https://github.com/nodejs/node/issues/16716
Refs: https://github.com/nodejs/node/pull/8895
PR-URL: https://github.com/nodejs/node/pull/16725
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'lib/_http_client.js')
-rw-r--r-- | lib/_http_client.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/_http_client.js b/lib/_http_client.js index fedadedcc2..df99daa9d5 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -728,9 +728,13 @@ ClientRequest.prototype.setTimeout = function setTimeout(msecs, callback) { } this.once('socket', function(sock) { - sock.once('connect', function() { + if (sock.connecting) { + sock.once('connect', function() { + sock.setTimeout(msecs, emitTimeout); + }); + } else { sock.setTimeout(msecs, emitTimeout); - }); + } }); return this; |