Fix compilation under mono #117. Allow explicit web client selection. Init curl at application start.

This commit is contained in:
KZ
2015-07-30 18:50:46 +01:00
parent c76137a70c
commit 922583ea5d
21 changed files with 139 additions and 59 deletions

View File

@@ -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()