Updating
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
namespace LCU.Library.Internal.ArchiverApi.Utilities;
|
||||
|
||||
public static class HttpUtilities
|
||||
{
|
||||
private const int ParamCounterDefault = 1;
|
||||
|
||||
public static HttpClient GetClient(string url)
|
||||
{
|
||||
var handler = new HttpClientHandler
|
||||
{
|
||||
SslProtocols = System.Security.Authentication.SslProtocols.Tls12 |
|
||||
System.Security.Authentication.SslProtocols.Tls11 |
|
||||
System.Security.Authentication.SslProtocols.Tls,
|
||||
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
|
||||
};
|
||||
|
||||
var httpClient = new HttpClient(handler)
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(60),
|
||||
BaseAddress = new Uri(url)
|
||||
};
|
||||
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
public static void AppendListOfValuesToEndpoint<T>(StringBuilder endpointBuilder, int currentIndex, List<T> listOfValues, string propertyName)
|
||||
{
|
||||
foreach (var value in listOfValues)
|
||||
{
|
||||
var splitter = currentIndex == 0 ? "?" : "&";
|
||||
endpointBuilder.Append($"{splitter}{propertyName}={value}");
|
||||
currentIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user