core: enable multiple redirects on download block fallback selectors (#12316) resolves #12314

This commit is contained in:
mikeoscar2006 2021-09-17 00:17:50 +05:30 committed by GitHub
parent ea4d1f5f94
commit 3ba6081766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -1727,11 +1727,16 @@ namespace Jackett.Common.Indexers
return response;
}
protected async Task<WebResult> HandleRedirectableRequestAsync(string url, Dictionary<string, string> headers = null)
protected async Task<WebResult> HandleRedirectableRequestAsync(string url, Dictionary<string, string> headers = null, int maxRedirects = 5)
{
var response = await RequestWithCookiesAsync(url, headers: headers);
if (response.IsRedirect)
response = await RequestWithCookiesAsync(response.RedirectingTo, headers: headers);
for (var i = 0; i < maxRedirects; i++)
{
if (response.IsRedirect)
response = await RequestWithCookiesAsync(response.RedirectingTo, headers: headers);
else
break;
}
return response;
}