Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snow 743920 cache https agent #563

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/http/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,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 = axios.request(requestOptions).then(response => {
Expand Down
10 changes: 10 additions & 0 deletions lib/http/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/integration/testLargeResultSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Loading