From 4531a876eb82a61101e7fc6607430c6bc6604ccf Mon Sep 17 00:00:00 2001 From: Cory Date: Sat, 14 Mar 2020 17:20:32 -0500 Subject: [PATCH] core: refactor http webclient part 2 #8529 (#7654) Use base class when not looking at content variable --- src/Jackett.Common/Indexers/BaseIndexer.cs | 14 ++------------ src/Jackett.Common/Indexers/CardigannIndexer.cs | 6 ++---- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/Jackett.Common/Indexers/BaseIndexer.cs b/src/Jackett.Common/Indexers/BaseIndexer.cs index 1cef37c62..69db2dfac 100644 --- a/src/Jackett.Common/Indexers/BaseIndexer.cs +++ b/src/Jackett.Common/Indexers/BaseIndexer.cs @@ -584,17 +584,7 @@ namespace Jackett.Common.Indexers } } - protected async Task FollowIfRedirect(WebClientStringResult response, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null, bool accumulateCookies = false) - { - var byteResult = new WebClientByteResult(); - // Map to byte - Mapper.Map(response, byteResult); - await FollowIfRedirect(byteResult, referrer, overrideRedirectUrl, overrideCookies, accumulateCookies); - // Map to string - Mapper.Map(byteResult, response); - } - - protected async Task FollowIfRedirect(WebClientByteResult response, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null, bool accumulateCookies = false) + protected async Task FollowIfRedirect(BaseWebResult response, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null, bool accumulateCookies = false) { // Follow up to 5 redirects for (var i = 0; i < 5; i++) @@ -639,7 +629,7 @@ namespace Jackett.Common.Indexers } } - private async Task DoFollowIfRedirect(WebClientByteResult incomingResponse, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null, bool accumulateCookies = false) + private async Task DoFollowIfRedirect(BaseWebResult incomingResponse, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null, bool accumulateCookies = false) { if (incomingResponse.IsRedirect) { diff --git a/src/Jackett.Common/Indexers/CardigannIndexer.cs b/src/Jackett.Common/Indexers/CardigannIndexer.cs index f1e2aac91..ef15fe2b0 100644 --- a/src/Jackett.Common/Indexers/CardigannIndexer.cs +++ b/src/Jackett.Common/Indexers/CardigannIndexer.cs @@ -782,9 +782,7 @@ namespace Jackett.Common.Indexers return null; } - protected string getRedirectDomainHint(WebClientByteResult result) => getRedirectDomainHint(result.Request.Url, result.RedirectingTo); - - protected string getRedirectDomainHint(WebClientStringResult result) => getRedirectDomainHint(result.Request.Url, result.RedirectingTo); + protected string getRedirectDomainHint(BaseWebResult result) => getRedirectDomainHint(result.Request.Url, result.RedirectingTo); protected async Task TestLogin() { @@ -828,7 +826,7 @@ namespace Jackett.Common.Indexers return true; } - protected bool CheckIfLoginIsNeeded(WebClientStringResult Result, IHtmlDocument document) + protected bool CheckIfLoginIsNeeded(BaseWebResult Result, IHtmlDocument document) { if (Result.IsRedirect) {