diff --git a/lib/http/base.js b/lib/http/base.js index 9f3302a1c..73757e65f 100644 --- a/lib/http/base.js +++ b/lib/http/base.js @@ -93,8 +93,12 @@ HttpClient.prototype.request = function (options) mock); requestOptions.data = requestOptions.body; - requestOptions.httpsAgent = agentAndProxyOptions.agentClass(agentAndProxyOptions.agentOptions); - requestOptions.httpsAgent.keepAlive = agentAndProxyOptions.agentOptions.keepAlive; + if (agentAndProxyOptions.httpsAgent) { + requestOptions.httpsAgent = agentAndProxyOptions.httpsAgent; + } else { + requestOptions.httpsAgent = agentAndProxyOptions.agentClass(agentAndProxyOptions.agentOptions); + requestOptions.httpsAgent.keepAlive = agentAndProxyOptions.agentOptions.keepAlive; + } requestOptions.retryDelay = this.constructExponentialBackoffStrategy(); request = require('urllib').request(requestOptions.url, requestOptions, async function (err, data, response) diff --git a/lib/http/node.js b/lib/http/node.js index 7d196f21e..6ee040cd3 100644 --- a/lib/http/node.js +++ b/lib/http/node.js @@ -41,12 +41,22 @@ function NodeHttpClient(connectionConfig) Util.inherits(NodeHttpClient, Base); +const defaultHttpsAgentOptions = { keepAlive: true }; +const defaultHttpsAgent = HttpsAgent(defaultHttpsAgentOptions); + /** * @inheritDoc */ NodeHttpClient.prototype.getAgentAndProxyOptions = function (url, proxy, mock) { const isHttps = Url.parse(url).protocol === 'https:'; + + if (isHttps && !proxy && !mock) { + return { + httpsAgent: defaultHttpsAgent, + }; + } + let agentClass; let agentOptions = { keepAlive: true }; let options; diff --git a/test/integration/testLargeResultSet.js b/test/integration/testLargeResultSet.js index 9b82518b9..973a1163e 100644 --- a/test/integration/testLargeResultSet.js +++ b/test/integration/testLargeResultSet.js @@ -263,13 +263,13 @@ describe('SNOW-743920: Large result set with ~35 chunks', function () { before(async () => { connection = testUtil.createConnection(); + configureLogger('TRACE'); await testUtil.connectAsync(connection); // setting ROWS_PER_RESULTSET causes invalid, not encoded chunks from GCP // await testUtil.executeCmdAsync(connection, 'alter session set ROWS_PER_RESULTSET = 1000000'); await testUtil.executeCmdAsync(connection, 'alter session set USE_CACHED_RESULT = false;'); await testUtil.executeCmdAsync(connection, createTable); await testUtil.executeCmdAsync(connection, populateData); - configureLogger('TRACE'); }); after(async () => {