Rename indexer proxied HTTP methods for clarification

pull/541/head
Qstick 3 years ago
parent 918071903b
commit 234995cbaf

@ -34,7 +34,7 @@ namespace NzbDrone.Core.Test.IndexerTests.AvistazTests
var recentFeed = ReadAllText(@"Files/Indexers/PrivateHD/recentfeed.json");
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader { { "Content-Type", "application/json" } }, new CookieCollection(), recentFeed)));
var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases;

@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests
var recentFeed = ReadAllText(@"Files/Indexers/FileList/recentfeed.json");
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed)));
var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases;

@ -45,7 +45,7 @@ namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests
var responseJson = ReadAllText(fileName);
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.POST), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.POST), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), responseJson)));
var torrents = (await Subject.Fetch(_movieSearchCriteria)).Releases;
@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests
var responseJson = new { status = 5, message = "Invalid authentication credentials" }.ToJson();
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.IsAny<HttpRequest>(), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.IsAny<HttpRequest>(), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), Encoding.UTF8.GetBytes(responseJson))));
var torrents = (await Subject.Fetch(_movieSearchCriteria)).Releases;

@ -43,7 +43,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
private void GivenCapsResponse(string caps)
{
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.Execute(It.IsAny<HttpRequest>(), It.IsAny<IndexerDefinition>()))
.Setup(o => o.ExecuteProxied(It.IsAny<HttpRequest>(), It.IsAny<IndexerDefinition>()))
.Returns<HttpRequest, IndexerDefinition>((r, d) => new HttpResponse(r, new HttpHeader(), new CookieCollection(), caps));
}
@ -56,7 +56,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
Subject.GetCapabilities(_settings, _definition);
Mocker.GetMock<IIndexerHttpClient>()
.Verify(o => o.Execute(It.IsAny<HttpRequest>(), It.IsAny<IndexerDefinition>()), Times.Once());
.Verify(o => o.ExecuteProxied(It.IsAny<HttpRequest>(), It.IsAny<IndexerDefinition>()), Times.Once());
}
[Test]
@ -85,7 +85,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
public void should_throw_if_failed_to_get()
{
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.Execute(It.IsAny<HttpRequest>(), It.IsAny<IndexerDefinition>()))
.Setup(o => o.ExecuteProxied(It.IsAny<HttpRequest>(), It.IsAny<IndexerDefinition>()))
.Throws<Exception>();
Assert.Throws<Exception>(() => Subject.GetCapabilities(_settings, _definition));

@ -43,7 +43,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
var recentFeed = ReadAllText(@"Files/Indexers/Newznab/newznab_nzb_su.xml");
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed)));
var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 }, Limit = 100, Offset = 0 })).Releases;

@ -37,11 +37,11 @@ namespace NzbDrone.Core.Test.IndexerTests.PTPTests
var responseJson = ReadAllText(fileName);
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.POST), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.POST), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), authStream.ToString())));
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader { ContentType = HttpAccept.Json.Value }, new CookieCollection(), responseJson)));
var torrents = (await Subject.Fetch(new MovieSearchCriteria())).Releases;

@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.IndexerTests.RarbgTests
var recentFeed = ReadAllText(@"Files/Indexers/Rarbg/RecentFeed_v2.json");
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed)));
var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases;
@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test.IndexerTests.RarbgTests
public async Task should_parse_error_20_as_empty_results()
{
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), "{ error_code: 20, error: \"some message\" }")));
var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases;
@ -77,7 +77,7 @@ namespace NzbDrone.Core.Test.IndexerTests.RarbgTests
public async Task should_warn_on_unknown_error()
{
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), "{ error_code: 25, error: \"some message\" }")));
var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases;

@ -44,7 +44,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
var recentFeed = ReadAllText(@"Files/Indexers/Torznab/torznab_hdaccess_net.xml");
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed)));
var releases = (await Subject.Fetch(new MovieSearchCriteria())).Releases;
@ -73,7 +73,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
var recentFeed = ReadAllText(@"Files/Indexers/Torznab/torznab_tpb.xml");
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed)));
var releases = (await Subject.Fetch(new MovieSearchCriteria())).Releases;
@ -103,7 +103,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
var recentFeed = ReadAllText(@"Files/Indexers/Torznab/torznab_animetosho.xml");
Mocker.GetMock<IIndexerHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET), Subject.Definition))
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed)));
var releases = (await Subject.Fetch(new MovieSearchCriteria())).Releases;

@ -52,7 +52,7 @@ namespace NzbDrone.Core.Indexers.Definitions
.SetCookies(GetCookies() ?? new Dictionary<string, string>())
.Build();
var response = await _httpClient.ExecuteAsync(request, Definition);
var response = await _httpClient.ExecuteProxiedAsync(request, Definition);
var parser = new HtmlParser();
var dom = parser.ParseDocument(response.Content);

@ -177,7 +177,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
try
{
var response = await _httpClient.ExecuteAsync(request, Definition);
var response = await _httpClient.ExecuteProxiedAsync(request, Definition);
downloadBytes = response.ResponseData;
}
catch (HttpException ex)

@ -194,7 +194,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
requestBuilder.Headers.Add("Referer", SiteLink);
var response = await HttpClient.ExecuteAsync(requestBuilder.Build(), Definition);
var response = await HttpClient.ExecuteProxiedAsync(requestBuilder.Build(), Definition);
Cookies = response.GetCookies();
@ -331,7 +331,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
requestBuilder.Headers.Add("Referer", loginUrl);
var simpleCaptchaResult = await HttpClient.ExecuteAsync(requestBuilder.Build(), Definition);
var simpleCaptchaResult = await HttpClient.ExecuteProxiedAsync(requestBuilder.Build(), Definition);
var simpleCaptchaJSON = JObject.Parse(simpleCaptchaResult.Content);
var captchaSelection = simpleCaptchaJSON["images"][0]["hash"].ToString();
@ -411,7 +411,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
var request = requestBuilder.Build();
request.SetContent(body);
loginResult = await HttpClient.ExecuteAsync(request, Definition);
loginResult = await HttpClient.ExecuteProxiedAsync(request, Definition);
}
else
{
@ -431,7 +431,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
requestBuilder.AddFormParameter(pair.Key, pair.Value);
}
loginResult = await HttpClient.ExecuteAsync(requestBuilder.Build(), Definition);
loginResult = await HttpClient.ExecuteProxiedAsync(requestBuilder.Build(), Definition);
}
Cookies = loginResult.GetCookies();
@ -466,7 +466,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
requestBuilder.Headers.Add("Referer", SiteLink);
var response = await HttpClient.ExecuteAsync(requestBuilder.Build(), Definition);
var response = await HttpClient.ExecuteProxiedAsync(requestBuilder.Build(), Definition);
Cookies = response.GetCookies();
@ -490,7 +490,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
requestBuilder.Headers.Add("Referer", SiteLink);
var response = await HttpClient.ExecuteAsync(requestBuilder.Build(), Definition);
var response = await HttpClient.ExecuteProxiedAsync(requestBuilder.Build(), Definition);
Cookies = response.GetCookies();
@ -569,7 +569,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
var request = requestBuilder.Build();
landingResult = await HttpClient.ExecuteAsync(request, Definition);
landingResult = await HttpClient.ExecuteProxiedAsync(request, Definition);
Cookies = landingResult.GetCookies();
@ -613,7 +613,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
.SetHeader("Referer", loginUrl.AbsoluteUri)
.Build();
var response = await HttpClient.ExecuteAsync(request, Definition);
var response = await HttpClient.ExecuteProxiedAsync(request, Definition);
return new Captcha
{
@ -703,7 +703,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
}
}
var response = await HttpClient.ExecuteAsync(httpRequest.Build(), Definition);
var response = await HttpClient.ExecuteProxiedAsync(httpRequest.Build(), Definition);
_logger.Debug($"CardigannIndexer ({_definition.Id}): handleRequest() remote server returned {response.StatusCode.ToString()}");
return response;
@ -743,7 +743,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
request.AllowAutoRedirect = true;
var response = await HttpClient.ExecuteAsync(request, Definition);
var response = await HttpClient.ExecuteProxiedAsync(request, Definition);
var results = response.Content;
var searchResultParser = new HtmlParser();

@ -63,7 +63,7 @@ namespace NzbDrone.Core.Indexers.Headphones
try
{
var response = await _httpClient.ExecuteAsync(request, Definition);
var response = await _httpClient.ExecuteProxiedAsync(request, Definition);
downloadBytes = response.ResponseData;
}
catch (Exception)

@ -56,7 +56,7 @@ namespace NzbDrone.Core.Indexers.Newznab
try
{
response = _httpClient.Execute(request, definition);
response = _httpClient.ExecuteProxied(request, definition);
}
catch (Exception ex)
{

@ -141,7 +141,7 @@ namespace NzbDrone.Core.Indexers.Definitions
try
{
var response = await _httpClient.ExecuteAsync(request, Definition);
var response = await _httpClient.ExecuteProxiedAsync(request, Definition);
torrentData = response.ResponseData;
}
catch (HttpException ex)

@ -379,7 +379,7 @@ namespace NzbDrone.Core.Indexers
request.HttpRequest.SuppressHttpError = true;
request.HttpRequest.Encoding = Encoding;
var response = await _httpClient.ExecuteAsync(request.HttpRequest, Definition);
var response = await _httpClient.ExecuteProxiedAsync(request.HttpRequest, Definition);
// Check reponse to see if auth is needed, if needed try again
if (CheckIfLoginNeeded(response))
@ -391,7 +391,7 @@ namespace NzbDrone.Core.Indexers
request.HttpRequest.Url = originalUrl;
ModifyRequest(request);
response = await _httpClient.ExecuteAsync(request.HttpRequest, Definition);
response = await _httpClient.ExecuteProxiedAsync(request.HttpRequest, Definition);
}
// Throw common http errors here before we try to parse
@ -414,7 +414,7 @@ namespace NzbDrone.Core.Indexers
{
request.Encoding = Encoding;
var response = await _httpClient.ExecuteAsync(request, Definition);
var response = await _httpClient.ExecuteProxiedAsync(request, Definition);
_eventAggregator.PublishEvent(new IndexerAuthEvent(Definition.Id, !response.HasHttpError, response.ElapsedTime));

@ -14,8 +14,8 @@ namespace NzbDrone.Core.Indexers
{
public interface IIndexerHttpClient : IHttpClient
{
Task<HttpResponse> ExecuteAsync(HttpRequest request, ProviderDefinition definition);
HttpResponse Execute(HttpRequest request, ProviderDefinition definition);
Task<HttpResponse> ExecuteProxiedAsync(HttpRequest request, ProviderDefinition definition);
HttpResponse ExecuteProxied(HttpRequest request, ProviderDefinition definition);
}
public class IndexerHttpClient : HttpClient, IIndexerHttpClient
@ -32,7 +32,7 @@ namespace NzbDrone.Core.Indexers
_indexerProxyFactory = indexerProxyFactory;
}
public async Task<HttpResponse> ExecuteAsync(HttpRequest request, ProviderDefinition definition)
public async Task<HttpResponse> ExecuteProxiedAsync(HttpRequest request, ProviderDefinition definition)
{
var selectedProxy = GetProxy(definition);
@ -41,7 +41,7 @@ namespace NzbDrone.Core.Indexers
return PostResponse(await ExecuteAsync(request), selectedProxy);
}
public HttpResponse Execute(HttpRequest request, ProviderDefinition definition)
public HttpResponse ExecuteProxied(HttpRequest request, ProviderDefinition definition)
{
var selectedProxy = GetProxy(definition);

@ -43,7 +43,7 @@ namespace NzbDrone.Core.Indexers
try
{
var response = await _httpClient.ExecuteAsync(request, Definition);
var response = await _httpClient.ExecuteProxiedAsync(request, Definition);
torrentData = response.ResponseData;
}
catch (HttpException ex)

@ -39,7 +39,7 @@ namespace NzbDrone.Core.Indexers
try
{
var response = await _httpClient.ExecuteAsync(request, Definition);
var response = await _httpClient.ExecuteProxiedAsync(request, Definition);
nzbData = response.ResponseData;
_logger.Debug("Downloaded nzb for release finished ({0} bytes from {1})", nzbData.Length, link.AbsoluteUri);

Loading…
Cancel
Save