Skip to content

Commit

Permalink
Added property to LoginRequestData to specify httpRequest timeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jmartinezramirez committed Oct 25, 2024
1 parent a806406 commit d84508b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Snowflake.Data/Core/Authenticator/IAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private SFRestRequest BuildLoginRequest()
};
SetSpecializedAuthenticatorData(ref data);

return session.BuildTimeoutRestRequest(loginUrl, new LoginRequest() { data = data });
return data.HttpTimeout.HasValue ? session.BuildTimeoutRestRequest(loginUrl, new LoginRequest() { data = data }, data.HttpTimeout.Value) : session.BuildTimeoutRestRequest(loginUrl, new LoginRequest() { data = data });
}
}

Expand Down
2 changes: 2 additions & 0 deletions Snowflake.Data/Core/Authenticator/MFACacheAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright (c) 2024 Snowflake Computing Inc. All rights reserved.
*/

using System;
using System.Threading;
using System.Threading.Tasks;
using Snowflake.Data.Core.Tools;
Expand Down Expand Up @@ -34,6 +35,7 @@ protected override void SetSpecializedAuthenticatorData(ref LoginRequestData dat
// Only need to add the password to Data for basic authentication
data.password = session.properties[SFSessionProperty.PASSWORD];
data.SessionParameters[SFSessionParameter.CLIENT_REQUEST_MFA_TOKEN] = true;
data.HttpTimeout = TimeSpan.FromSeconds(60);
if (!string.IsNullOrEmpty(session._mfaToken?.ToString()))
{
data.Token = SecureStringHelper.Decode(session._mfaToken);
Expand Down
3 changes: 3 additions & 0 deletions Snowflake.Data/Core/RestRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ class LoginRequestData
[JsonProperty(PropertyName = "SESSION_PARAMETERS", NullValueHandling = NullValueHandling.Ignore)]
internal Dictionary<SFSessionParameter, Object> SessionParameters { get; set; }

[JsonIgnore]
internal TimeSpan? HttpTimeout { get; set; }

public override string ToString()
{
return String.Format("LoginRequestData {{ClientAppVersion: {0},\n AccountName: {1},\n loginName: {2},\n ClientEnv: {3},\n authenticator: {4} }}",
Expand Down
13 changes: 13 additions & 0 deletions Snowflake.Data/Core/Session/SFSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,19 @@ internal SFRestRequest BuildTimeoutRestRequest(Uri uri, Object body)
};
}

internal SFRestRequest BuildTimeoutRestRequest(Uri uri, Object body, TimeSpan httpTimeout)
{
return new SFRestRequest()
{
jsonBody = body,
Url = uri,
authorizationToken = SF_AUTHORIZATION_BASIC,
RestTimeout = connectionTimeout,
HttpTimeout = httpTimeout,
_isLogin = true
};
}

internal void UpdateSessionParameterMap(List<NameValueParameter> parameterList)
{
logger.Debug("Update parameter map");
Expand Down

0 comments on commit d84508b

Please sign in to comment.