mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Fix compilation under mono #117. Allow explicit web client selection. Init curl at application start.
This commit is contained in:
@@ -178,15 +178,30 @@ namespace Jackett.Indexers
|
||||
|
||||
public async virtual Task<byte[]> Download(Uri link)
|
||||
{
|
||||
var response = await webclient.GetBytes(new Utils.Clients.WebRequest()
|
||||
{
|
||||
Url = link.ToString(),
|
||||
Cookies = cookieHeader
|
||||
});
|
||||
|
||||
var response = await RequestBytesWithCookiesAndRetry(link.ToString());
|
||||
return response.Content;
|
||||
}
|
||||
|
||||
protected async Task<WebClientByteResult> RequestBytesWithCookiesAndRetry(string url, string cookieOverride = null)
|
||||
{
|
||||
Exception lastException = null;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await RequestBytesWithCookies(url, cookieOverride);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(string.Format("On attempt {0} downloading from {1}: {2}", (i + 1), DisplayName, e.Message));
|
||||
lastException = e;
|
||||
await Task.Delay(500);
|
||||
}
|
||||
}
|
||||
|
||||
throw lastException;
|
||||
}
|
||||
|
||||
protected async Task<WebClientStringResult> RequestStringWithCookies(string url, string cookieOverride = null, string referer = null)
|
||||
{
|
||||
var request = new Utils.Clients.WebRequest()
|
||||
|
Reference in New Issue
Block a user