mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 21:13:28 -07:00
Fix HttpClientTests, Use Servarr HttpBin Mirror
This commit is contained in:
parent
f5e2a447e9
commit
3af96f1863
2 changed files with 5 additions and 3 deletions
|
@ -46,7 +46,7 @@ namespace NzbDrone.Common.Test.Http
|
||||||
|
|
||||||
TestLogger.Info($"{candidates.Length} TestSites available.");
|
TestLogger.Info($"{candidates.Length} TestSites available.");
|
||||||
|
|
||||||
_httpBinSleep = _httpBinHosts.Length < 2 ? 100 : 10;
|
_httpBinSleep = _httpBinHosts.Count() < 2 ? 100 : 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsTestSiteAvailable(string site)
|
private bool IsTestSiteAvailable(string site)
|
||||||
|
@ -250,7 +250,7 @@ namespace NzbDrone.Common.Test.Http
|
||||||
[Test]
|
[Test]
|
||||||
public void should_throw_on_too_many_redirects()
|
public void should_throw_on_too_many_redirects()
|
||||||
{
|
{
|
||||||
var request = new HttpRequest($"https://{_httpBinHost}/redirect/4");
|
var request = new HttpRequest($"https://{_httpBinHost}/redirect/6");
|
||||||
request.AllowAutoRedirect = true;
|
request.AllowAutoRedirect = true;
|
||||||
|
|
||||||
Assert.Throws<WebException>(() => Subject.Get(request));
|
Assert.Throws<WebException>(() => Subject.Get(request));
|
||||||
|
|
|
@ -28,6 +28,8 @@ namespace NzbDrone.Common.Http
|
||||||
|
|
||||||
public class HttpClient : IHttpClient
|
public class HttpClient : IHttpClient
|
||||||
{
|
{
|
||||||
|
private const int MaxRedirects = 5;
|
||||||
|
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
private readonly IRateLimitService _rateLimitService;
|
private readonly IRateLimitService _rateLimitService;
|
||||||
private readonly ICached<CookieContainer> _cookieContainerCache;
|
private readonly ICached<CookieContainer> _cookieContainerCache;
|
||||||
|
@ -70,7 +72,7 @@ namespace NzbDrone.Common.Http
|
||||||
|
|
||||||
_logger.Trace("Redirected to {0}", request.Url);
|
_logger.Trace("Redirected to {0}", request.Url);
|
||||||
|
|
||||||
if (autoRedirectChain.Count > 3)
|
if (autoRedirectChain.Count > MaxRedirects)
|
||||||
{
|
{
|
||||||
throw new WebException($"Too many automatic redirections were attempted for {autoRedirectChain.Join(" -> ")}", WebExceptionStatus.ProtocolError);
|
throw new WebException($"Too many automatic redirections were attempted for {autoRedirectChain.Join(" -> ")}", WebExceptionStatus.ProtocolError);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue