mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-09-14 14:27:24 -04:00
Fix Transmission connections failing when the 409 session challenge is retried (#714)
This commit is contained in:
1 parent
f541cfa97c
commit
f7e3ba4196
3 files changed
+117
-9
No files matched your search
+16
-9
@@ -103,15 +103,7 @@ public class DynamicHttpClientConfiguration : IConfigureNamedOptions<HttpClientF
|
||||
var retryPolicy = HttpPolicyExtensions
|
||||
.HandleTransientHttpError();
|
||||
|
||||
if (retryConfig.ExcludeUnauthorized)
|
||||
{
|
||||
retryPolicy = retryPolicy.OrResult(response =>
|
||||
!response.IsSuccessStatusCode && response.StatusCode != HttpStatusCode.Unauthorized);
|
||||
}
|
||||
else
|
||||
{
|
||||
retryPolicy = retryPolicy.OrResult(response => !response.IsSuccessStatusCode);
|
||||
}
|
||||
retryPolicy = retryPolicy.OrResult(response => IsRetryable(response, retryConfig.ExcludeUnauthorized));
|
||||
|
||||
var policy = retryPolicy.WaitAndRetryAsync(
|
||||
retryConfig.MaxRetries,
|
||||
@@ -121,6 +113,21 @@ public class DynamicHttpClientConfiguration : IConfigureNamedOptions<HttpClientF
|
||||
builder.AdditionalHandlers.Add(new PolicyHttpMessageHandler(policy));
|
||||
}
|
||||
|
||||
internal static bool IsRetryable(HttpResponseMessage response, bool excludeUnauthorized)
|
||||
{
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (response.StatusCode is HttpStatusCode.Conflict)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !excludeUnauthorized || response.StatusCode != HttpStatusCode.Unauthorized;
|
||||
}
|
||||
|
||||
public void Configure(HttpClientFactoryOptions options)
|
||||
{
|
||||
// This is called for unnamed clients - we don't need to do anything here
|
||||
|
||||
Reference in new issue
Block a user