Skip to content

Commit

Permalink
core: refactor http webclient part 2 #8529 (#7654)
Browse files Browse the repository at this point in the history
Use base class when not looking at content variable
  • Loading branch information
cadatoiva authored and ngosang committed Sep 21, 2020
1 parent d760350 commit 4531a87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
14 changes: 2 additions & 12 deletions src/Jackett.Common/Indexers/BaseIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,17 +584,7 @@ protected void CheckTrackerDown(WebClientStringResult response)
}
}

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++)
Expand Down Expand Up @@ -639,7 +629,7 @@ protected virtual void UpdateCookieHeader(string newCookies, string cookieOverri
}
}

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)
{
Expand Down
6 changes: 2 additions & 4 deletions src/Jackett.Common/Indexers/CardigannIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,7 @@ protected string getRedirectDomainHint(string requestUrl, string RedirectUrl)
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<bool> TestLogin()
{
Expand Down Expand Up @@ -828,7 +826,7 @@ protected async Task<bool> TestLogin()
return true;
}

protected bool CheckIfLoginIsNeeded(WebClientStringResult Result, IHtmlDocument document)
protected bool CheckIfLoginIsNeeded(BaseWebResult Result, IHtmlDocument document)
{
if (Result.IsRedirect)
{
Expand Down

0 comments on commit 4531a87

Please sign in to comment.