core: refactor http webclient part 13 #8529 (#8941)

Merge string/byte request code
This commit is contained in:
Cory
2020-06-11 10:09:27 -05:00
committed by ngosang
parent 67c7b4ca70
commit ac0ba0f9b1
91 changed files with 330 additions and 399 deletions

View File

@@ -14,6 +14,7 @@ using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;
using static Jackett.Common.Models.IndexerConfig.ConfigurationData;
@@ -150,13 +151,13 @@ namespace Jackett.Common.Indexers
// Make search request
var searchUri = GetAbsoluteUrl("?" + queryParameters.GetQueryString());
var response = await RequestStringWithCookiesAndRetry(searchUri.AbsoluteUri);
var response = await RequestWithCookiesAndRetryAsync(searchUri.AbsoluteUri);
// Check for DDOS Guard
if (response.Status == System.Net.HttpStatusCode.Forbidden)
{
await ConfigureDDoSGuardCookie();
response = await RequestStringWithCookiesAndRetry(searchUri.AbsoluteUri);
response = await RequestWithCookiesAndRetryAsync(searchUri.AbsoluteUri);
}
if (response.Status != System.Net.HttpStatusCode.OK)
@@ -216,7 +217,7 @@ namespace Jackett.Common.Indexers
private async Task ConfigureDDoSGuardCookie()
{
const string ddosPostUrl = "https://check.ddos-guard.net/check.js";
var response = await RequestStringWithCookies(ddosPostUrl, string.Empty);
var response = await WebRequestWithCookiesAsync(ddosPostUrl, string.Empty);
if (response.Status != System.Net.HttpStatusCode.OK)
throw new WebException($"Unexpected DDOS Guard response: Status: {response.Status}", WebExceptionStatus.ProtocolError);
if (response.IsRedirect)