|
|
@ -390,6 +390,11 @@ namespace NzbDrone.Core.Indexers
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual bool CheckIfLoginNeeded(HttpResponse httpResponse)
|
|
|
|
protected virtual bool CheckIfLoginNeeded(HttpResponse httpResponse)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (httpResponse.StatusCode == HttpStatusCode.Unauthorized)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -425,6 +430,7 @@ namespace NzbDrone.Core.Indexers
|
|
|
|
|
|
|
|
|
|
|
|
var stopWatch = Stopwatch.StartNew();
|
|
|
|
var stopWatch = Stopwatch.StartNew();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
request.HttpRequest.SuppressHttpError = true;
|
|
|
|
var response = _httpClient.Execute(request.HttpRequest);
|
|
|
|
var response = _httpClient.Execute(request.HttpRequest);
|
|
|
|
|
|
|
|
|
|
|
|
stopWatch.Stop();
|
|
|
|
stopWatch.Stop();
|
|
|
@ -448,6 +454,21 @@ namespace NzbDrone.Core.Indexers
|
|
|
|
response = _httpClient.Execute(request.HttpRequest);
|
|
|
|
response = _httpClient.Execute(request.HttpRequest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Throw any other http error we get after attempting auth
|
|
|
|
|
|
|
|
if (response.HasHttpError)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.Warn("HTTP Error - {0}", response);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((int)response.StatusCode == 429)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new TooManyRequestsException(request.HttpRequest, response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new HttpException(request.HttpRequest, response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UpdateCookies(Cookies, DateTime.Now + TimeSpan.FromDays(30));
|
|
|
|
UpdateCookies(Cookies, DateTime.Now + TimeSpan.FromDays(30));
|
|
|
|
|
|
|
|
|
|
|
|
return new IndexerResponse(request, response, stopWatch.ElapsedMilliseconds);
|
|
|
|
return new IndexerResponse(request, response, stopWatch.ElapsedMilliseconds);
|
|
|
|