diff options
author | Luigi Pinca <luigipinca@gmail.com> | 2016-10-02 12:10:33 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2017-09-20 10:41:13 -0300 |
commit | 10be20a0e88f2b8aa354884a418b92c331fe078d (patch) | |
tree | ae1debaf81d2d421d881811d8c0ea9fa73501874 /lib/_http_client.js | |
parent | c5eb5bfc2e2cb659db1ce3c12f77ad8f8834d3d8 (diff) | |
download | android-node-v8-10be20a0e88f2b8aa354884a418b92c331fe078d.tar.gz android-node-v8-10be20a0e88f2b8aa354884a418b92c331fe078d.tar.bz2 android-node-v8-10be20a0e88f2b8aa354884a418b92c331fe078d.zip |
http: set socket timeout when socket connects
`request.setTimeout()` calls `socket.setTimeout()` as soon as a socket
is assigned to the request. This makes the `timeout` event to be
emitted on the request even if the underlying socket never connects.
This commit makes `socket.setTimeout()` to be called only when the
underlying socket is connected.
PR-URL: https://github.com/nodejs/node/pull/8895
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'lib/_http_client.js')
-rw-r--r-- | lib/_http_client.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/_http_client.js b/lib/_http_client.js index e972a3d5b9..a0e4fb2507 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -739,7 +739,9 @@ ClientRequest.prototype.setTimeout = function setTimeout(msecs, callback) { } this.once('socket', function(sock) { - sock.setTimeout(msecs, emitTimeout); + sock.once('connect', function() { + sock.setTimeout(msecs, emitTimeout); + }); }); return this; |