39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
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++;
|
|
}
|
|
}
|
|
} |