pull/1614/head
tidusjar 7 years ago
parent 769ddccb90
commit c00a0d1f2f

@ -13,15 +13,19 @@ namespace Ombi.Api
public Api(ILogger<Api> log) public Api(ILogger<Api> log)
{ {
Logger = log; Logger = log;
_handler = new HttpClientHandler }
private ILogger<Api> Logger { get; }
private HttpMessageHandler GetHandler()
{
return new HttpClientHandler
{ {
ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true
}; };
} }
private ILogger<Api> Logger { get; }
private readonly HttpMessageHandler _handler;
private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{ {
NullValueHandling = NullValueHandling.Ignore NullValueHandling = NullValueHandling.Ignore
@ -29,7 +33,7 @@ namespace Ombi.Api
public async Task<T> Request<T>(Request request) public async Task<T> Request<T>(Request request)
{ {
using (var httpClient = new HttpClient(_handler)) using (var httpClient = new HttpClient(GetHandler()))
{ {
using (var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.FullUri)) using (var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.FullUri))
@ -75,7 +79,7 @@ namespace Ombi.Api
public async Task<string> RequestContent(Request request) public async Task<string> RequestContent(Request request)
{ {
using (var httpClient = new HttpClient(_handler)) using (var httpClient = new HttpClient(GetHandler()))
{ {
using (var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.FullUri)) using (var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.FullUri))
{ {
@ -109,7 +113,7 @@ namespace Ombi.Api
public async Task Request(Request request) public async Task Request(Request request)
{ {
using (var httpClient = new HttpClient(_handler)) using (var httpClient = new HttpClient(GetHandler()))
{ {
using (var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.FullUri)) using (var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.FullUri))
{ {

Loading…
Cancel
Save