Release 0.3.4: Jellyfin 12 stable support and audit fixes
Harden proxy permissions and cache behavior, streamline metadata fetching, remove obsolete rules, and validate the stable SDK with expanded regression coverage. Document backup format changes.
This commit is contained in:
@@ -39,29 +39,33 @@ public static class ProviderHttp
|
||||
public static async Task<HttpResponseMessage> SendWithRetryAsync(
|
||||
HttpClient http,
|
||||
HttpRequestMessage request,
|
||||
CancellationToken cancellationToken)
|
||||
CancellationToken cancellationToken,
|
||||
FetchRateLimiter? rateLimiter = null)
|
||||
{
|
||||
const int maxAttempts = 3;
|
||||
for (var attempt = 1; attempt <= maxAttempts; attempt++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await http.SendAsync(Clone(request), cancellationToken).ConfigureAwait(false);
|
||||
if (rateLimiter is not null)
|
||||
await rateLimiter.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
using var attemptRequest = Clone(request);
|
||||
var response = await http.SendAsync(attemptRequest, cancellationToken).ConfigureAwait(false);
|
||||
Record(request, "HTTP " + (int)response.StatusCode, attempt);
|
||||
if (response.IsSuccessStatusCode || Classify(response.StatusCode) == ProviderFailureKind.Terminal || attempt == maxAttempts)
|
||||
{
|
||||
Record(request, "HTTP " + (int)response.StatusCode, attempt);
|
||||
return response;
|
||||
}
|
||||
|
||||
var delay = GetRetryDelay(response, attempt);
|
||||
response.Dispose();
|
||||
await Task.Delay(delay, cancellationToken).ConfigureAwait(false);
|
||||
await Task.Delay(delay < TimeSpan.Zero ? TimeSpan.Zero : delay, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception ex) when (!cancellationToken.IsCancellationRequested && ex is HttpRequestException or OperationCanceledException)
|
||||
{
|
||||
Record(request, ex.GetType().Name, attempt);
|
||||
if (attempt >= maxAttempts)
|
||||
{
|
||||
Record(request, ex.GetType().Name, attempt);
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user