2020-02-14 22:23:27 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Net;
|
2021-02-04 03:48:30 +00:00
|
|
|
|
using System.Net.Security;
|
|
|
|
|
using System.Security.Authentication;
|
|
|
|
|
using Wabbajack.Common;
|
2020-02-14 22:23:27 +00:00
|
|
|
|
using SysHttp = System.Net.Http;
|
2020-06-26 17:08:30 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Lib.Http
|
2020-02-14 22:23:27 +00:00
|
|
|
|
{
|
|
|
|
|
public static class ClientFactory
|
|
|
|
|
{
|
|
|
|
|
private static SysHttp.SocketsHttpHandler _socketsHandler { get; }
|
2020-03-03 21:53:29 +00:00
|
|
|
|
public static SysHttp.HttpClient Client { get; }
|
2020-02-14 22:23:27 +00:00
|
|
|
|
internal static CookieContainer Cookies { get; }
|
|
|
|
|
|
|
|
|
|
static ClientFactory()
|
|
|
|
|
{
|
|
|
|
|
Cookies = new CookieContainer();
|
|
|
|
|
_socketsHandler = new SysHttp.SocketsHttpHandler
|
|
|
|
|
{
|
|
|
|
|
CookieContainer = Cookies,
|
2020-02-26 05:05:33 +00:00
|
|
|
|
MaxConnectionsPerServer = 20,
|
|
|
|
|
PooledConnectionLifetime = TimeSpan.FromMilliseconds(100),
|
2021-02-04 03:48:30 +00:00
|
|
|
|
PooledConnectionIdleTimeout = TimeSpan.FromMilliseconds(100),
|
2021-02-17 05:46:05 +00:00
|
|
|
|
AutomaticDecompression = DecompressionMethods.All
|
2021-02-04 03:48:30 +00:00
|
|
|
|
|
2020-02-14 22:23:27 +00:00
|
|
|
|
};
|
2021-02-04 03:48:30 +00:00
|
|
|
|
Utils.Log($"Configuring with SSL {_socketsHandler.SslOptions.EnabledSslProtocols}");
|
2020-02-14 22:23:27 +00:00
|
|
|
|
Client = new SysHttp.HttpClient(_socketsHandler);
|
2021-04-11 22:04:12 +00:00
|
|
|
|
Client.DefaultRequestHeaders.Add("User-Agent", Consts.UserAgent);
|
2020-02-14 22:23:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|