Skip to content

Commit 67178e6

Browse files
committed
Added Timeout and UserAgent headers to asynchronous calls with rest sharp upgrade
1 parent 23dd3cf commit 67178e6

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

cybersource-rest-client-netstandard/cybersource-rest-client-netstandard/Client/ApiClient.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,14 +558,19 @@ public async System.Threading.Tasks.Task<object> CallApiAsync(
558558
}
559559
}
560560

561-
if (logUtility.IsMaskingEnabled(logger))
562-
{
563-
logger.Debug($"HTTP Request Headers :\n{logUtility.MaskSensitiveData(headerPrintOutput.ToString())}");
564-
}
565-
else
566-
{
567-
logger.Debug($"HTTP Request Headers :\n{headerPrintOutput.ToString()}");
568-
}
561+
// set timeout
562+
request.Timeout = Configuration.Timeout;
563+
// set user agent
564+
RestClient.Options.UserAgent = Configuration.UserAgent;
565+
566+
if (logUtility.IsMaskingEnabled(logger))
567+
{
568+
logger.Debug($"HTTP Request Headers :\n{logUtility.MaskSensitiveData(headerPrintOutput.ToString())}");
569+
}
570+
else
571+
{
572+
logger.Debug($"HTTP Request Headers :\n{headerPrintOutput.ToString()}");
573+
}
569574

570575
InterceptRequest(request);
571576
var response = await RestClient.ExecuteAsync(request);

cybersource-rest-client-netstandard/cybersource-rest-client-netstandard/generator/cybersource-csharp-template/ApiClient.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,9 @@ namespace {{packageName}}.Client
613613
}
614614

615615
// set timeout
616-
RestClient.Timeout = Configuration.Timeout;
616+
request.Timeout = Configuration.Timeout;
617617
// set user agent
618-
RestClient.UserAgent = Configuration.UserAgent;
618+
RestClient.Options.UserAgent = Configuration.UserAgent;
619619

620620
if (logUtility.IsMaskingEnabled(logger))
621621
{

0 commit comments

Comments
 (0)