mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-25 15:22:42 +00: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 @@ public void FixtureSetUp()
|
|||
|
||||
TestLogger.Info($"{candidates.Length} TestSites available.");
|
||||
|
||||
_httpBinSleep = _httpBinHosts.Length < 2 ? 100 : 10;
|
||||
_httpBinSleep = _httpBinHosts.Count() < 2 ? 100 : 10;
|
||||
}
|
||||
|
||||
private bool IsTestSiteAvailable(string site)
|
||||
|
@ -250,7 +250,7 @@ public void should_follow_redirects_to_https()
|
|||
[Test]
|
||||
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;
|
||||
|
||||
Assert.Throws<WebException>(() => Subject.Get(request));
|
||||
|
|
|
@ -28,6 +28,8 @@ HttpResponse<T> Post<T>(HttpRequest request)
|
|||
|
||||
public class HttpClient : IHttpClient
|
||||
{
|
||||
private const int MaxRedirects = 5;
|
||||
|
||||
private readonly Logger _logger;
|
||||
private readonly IRateLimitService _rateLimitService;
|
||||
private readonly ICached<CookieContainer> _cookieContainerCache;
|
||||
|
@ -70,7 +72,7 @@ public HttpResponse Execute(HttpRequest request)
|
|||
|
||||
_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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue