diff options
author | Bryan English <bryan@bryanenglish.com> | 2017-05-25 00:32:04 -0700 |
---|---|---|
committer | Bryan English <bryan@bryanenglish.com> | 2017-09-27 18:31:17 -0700 |
commit | 2043944a4c62de60e7a04e8c914b565114c4b11b (patch) | |
tree | 8968545721889a1b539057b9b60576da60341a1a /lib/_http_client.js | |
parent | 510cab7a3d12ee95e0b04f9682c07d0d8a8d84a5 (diff) | |
download | android-node-v8-2043944a4c62de60e7a04e8c914b565114c4b11b.tar.gz android-node-v8-2043944a4c62de60e7a04e8c914b565114c4b11b.tar.bz2 android-node-v8-2043944a4c62de60e7a04e8c914b565114c4b11b.zip |
http: client keep-alive for UNIX domain sockets
Makes `Connection: keep-alive` behave correctly when making client
connections to UNIX domain sockets.
Prior to this, connections would never be re-used, but the keep-alive
would cause the connections to stick around until they time out. This
would lead to an eventual EMFILE error due to all the connections
staying open. This was due to http.Agent not properly supporting UNIX
domain sockets.
PR-URL: https://github.com/nodejs/node/pull/13214
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/_http_client.js')
-rw-r--r-- | lib/_http_client.js | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/lib/_http_client.js b/lib/_http_client.js index a0e4fb2507..6eb7d34fc5 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -240,23 +240,7 @@ function ClientRequest(options, cb) { this._deferToConnect(null, null, () => this._flush()); }; - var newSocket; - if (this.socketPath) { - this._last = true; - this.shouldKeepAlive = false; - var optionsPath = { - path: this.socketPath, - timeout: this.timeout, - rejectUnauthorized: !!options.rejectUnauthorized - }; - newSocket = this.agent.createConnection(optionsPath, oncreate); - if (newSocket && !called) { - called = true; - this.onSocket(newSocket); - } else { - return; - } - } else if (this.agent) { + if (this.agent) { // If there is an agent we should default to Connection:keep-alive, // but only if the Agent will actually reuse the connection! // If it's not a keepAlive agent, and the maxSockets==Infinity, then @@ -274,7 +258,7 @@ function ClientRequest(options, cb) { this._last = true; this.shouldKeepAlive = false; if (typeof options.createConnection === 'function') { - newSocket = options.createConnection(options, oncreate); + const newSocket = options.createConnection(options, oncreate); if (newSocket && !called) { called = true; this.onSocket(newSocket); |