mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-04-19 19:30:47 +02:00
Fixed: Suppress HTTP Errors on initial indexer call until after re-auth attempt
This commit is contained in:
parent
7fa4b322eb
commit
a85653b716
2 changed files with 21 additions and 1 deletions
|
|
@ -889,7 +889,6 @@ private IEnumerable<IndexerRequest> GetRequest(Dictionary<string, object> variab
|
|||
}
|
||||
|
||||
request.HttpRequest.Method = method;
|
||||
request.HttpRequest.SuppressHttpError = true;
|
||||
|
||||
yield return request;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -390,6 +390,11 @@ protected virtual IndexerQueryResult FetchPage(IndexerRequest request, IParseInd
|
|||
|
||||
protected virtual bool CheckIfLoginNeeded(HttpResponse httpResponse)
|
||||
{
|
||||
if (httpResponse.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -425,6 +430,7 @@ protected virtual IndexerResponse FetchIndexerResponse(IndexerRequest request)
|
|||
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
|
||||
request.HttpRequest.SuppressHttpError = true;
|
||||
var response = _httpClient.Execute(request.HttpRequest);
|
||||
|
||||
stopWatch.Stop();
|
||||
|
|
@ -448,6 +454,21 @@ protected virtual IndexerResponse FetchIndexerResponse(IndexerRequest request)
|
|||
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));
|
||||
|
||||
return new IndexerResponse(request, response, stopWatch.ElapsedMilliseconds);
|
||||
|
|
|
|||
Loading…
Reference in a new issue