mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Improve error handling if the tracker is down
This commit is contained in:
@@ -336,6 +336,7 @@ namespace Jackett.Indexers
|
|||||||
if (cookieOverride != null)
|
if (cookieOverride != null)
|
||||||
request.Cookies = cookieOverride;
|
request.Cookies = cookieOverride;
|
||||||
WebClientStringResult result = await webclient.GetString(request);
|
WebClientStringResult result = await webclient.GetString(request);
|
||||||
|
CheckTrackerDown(result);
|
||||||
UpdateCookieHeader(result.Cookies, cookieOverride);
|
UpdateCookieHeader(result.Cookies, cookieOverride);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -395,6 +396,7 @@ namespace Jackett.Indexers
|
|||||||
if (emulateBrowser.HasValue)
|
if (emulateBrowser.HasValue)
|
||||||
request.EmulateBrowser = emulateBrowser.Value;
|
request.EmulateBrowser = emulateBrowser.Value;
|
||||||
WebClientStringResult result = await webclient.GetString(request);
|
WebClientStringResult result = await webclient.GetString(request);
|
||||||
|
CheckTrackerDown(result);
|
||||||
UpdateCookieHeader(result.Cookies, cookieOverride);
|
UpdateCookieHeader(result.Cookies, cookieOverride);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -431,6 +433,7 @@ namespace Jackett.Indexers
|
|||||||
Encoding = Encoding
|
Encoding = Encoding
|
||||||
};
|
};
|
||||||
var response = await webclient.GetString(request);
|
var response = await webclient.GetString(request);
|
||||||
|
CheckTrackerDown(response);
|
||||||
if (accumulateCookies)
|
if (accumulateCookies)
|
||||||
{
|
{
|
||||||
response.Cookies = ResolveCookies((request.Cookies == null ? "" : request.Cookies + " ") + response.Cookies);
|
response.Cookies = ResolveCookies((request.Cookies == null ? "" : request.Cookies + " ") + response.Cookies);
|
||||||
@@ -450,6 +453,18 @@ namespace Jackett.Indexers
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void CheckTrackerDown(WebClientStringResult response)
|
||||||
|
{
|
||||||
|
if (response.Status == System.Net.HttpStatusCode.BadGateway
|
||||||
|
|| response.Status == System.Net.HttpStatusCode.GatewayTimeout
|
||||||
|
|| (int)response.Status == 521 // used by cloudflare to signal the original webserver is refusing the connection
|
||||||
|
|| (int)response.Status == 522 // used by cloudflare to signal the original webserver is not reachable at all (timeout)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
throw new Exception("Request to " + response.Request.Url + " failed (Error " + response.Status + ") - The tracker seems to be down.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected async Task FollowIfRedirect(WebClientStringResult response, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null, bool accumulateCookies = false)
|
protected async Task FollowIfRedirect(WebClientStringResult response, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null, bool accumulateCookies = false)
|
||||||
{
|
{
|
||||||
var byteResult = new WebClientByteResult();
|
var byteResult = new WebClientByteResult();
|
||||||
|
Reference in New Issue
Block a user