protected virtual IList <ReleaseInfo> FetchPage(IndexerRequest request, IParseIndexerResponse parser) { var response = FetchIndexerResponse(request); try { return(parser.ParseResponse(response).ToList()); } catch (Exception ex) { ex.WithData(response.HttpResponse, 128 * 1024); _logger.Trace("Unexpected Response content ({0} bytes): {1}", response.HttpResponse.ResponseData.Length, response.HttpResponse.Content); throw; } }
protected virtual IndexerResponse FetchIndexerResponse(IndexerRequest request) { _logger.Debug("Downloading Feed " + request.HttpRequest.ToString(false)); if (request.HttpRequest.RateLimit < RateLimit) { request.HttpRequest.RateLimit = RateLimit; } request.HttpRequest.RateLimitKey = Definition.Id.ToString(); request.HttpRequest.AllowAutoRedirect = true; return(new IndexerResponse(request, _httpClient.Execute(request.HttpRequest))); }
public IndexerResponse(IndexerRequest indexerRequest, HttpResponse httpResponse) { _indexerRequest = indexerRequest; _httpResponse = httpResponse; }
protected virtual IList <ReleaseInfo> FetchPage(IndexerRequest request, IParseIndexerResponse parser) { var response = FetchIndexerResponse(request); return(parser.ParseResponse(response).ToList()); }
public IndexerResponse(IndexerRequest indexerRequest, HttpResponse httpResponse) { _indexerRequest = indexerRequest; _httpResponse = httpResponse; }
protected virtual async Task <IndexerResponse> FetchIndexerResponse(IndexerRequest request) { _logger.Debug("Downloading Feed " + request.HttpRequest.ToString(false)); if (request.HttpRequest.RateLimit < RateLimit) { request.HttpRequest.RateLimit = RateLimit; } if (_configService.LogIndexerResponse) { request.HttpRequest.LogResponseContent = true; } request.HttpRequest.AllowAutoRedirect = FollowRedirect; var originalUrl = request.Url; Cookies = GetCookies(); if (Cookies != null) { foreach (var cookie in Cookies) { request.HttpRequest.Cookies.Add(cookie.Key, cookie.Value); } } request.HttpRequest.SuppressHttpError = true; request.HttpRequest.Encoding = request.HttpRequest.Encoding ?? Encoding; var response = await _httpClient.ExecuteProxiedAsync(request.HttpRequest, Definition); // Check reponse to see if auth is needed, if needed try again if (CheckIfLoginNeeded(response)) { _logger.Trace("Attempting to re-auth based on indexer search response"); await DoLogin(); request.HttpRequest.Url = originalUrl; ModifyRequest(request); response = await _httpClient.ExecuteProxiedAsync(request.HttpRequest, Definition); } // Throw common http errors here before we try to parse if (response.HasHttpError) { _logger.Warn("HTTP Error - {0}", response); if ((int)response.StatusCode == 429) { throw new TooManyRequestsException(request.HttpRequest, response); } } UpdateCookies(Cookies, DateTime.Now + TimeSpan.FromDays(30)); return(new IndexerResponse(request, response)); }