Raccolta: 429 del CDN come rallentamento, attese crescenti e recupero dei falliti, storico e seguiti senza pagina di ripresa, lacuna sotto la prima pagina, eliminazioni durante lo scaricamento (regole-3, cdn-429, dl-1, post-loop, walk-1, check-1, scroll-1, reader-1, h9-1, ring-1, library-2, dedup-1, tmp-1, budget-1, regole-4, kind-1, vocab-1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
Claude committed 2026-10-14 00:23:03 +00:00
1 parent 78c92eb2a4
commit b16e3a837d
28 files changed
+2619 -200

No files matched your search

@@ -99,6 +99,15 @@ public sealed class BrowserFileFetcher : IFileFetcher
return new FetchResult(FetchOutcome.NetworkError, 0, status, "Il browser non ha aperto il flusso dei dati.");
}
// The browser hands out the stream only once the whole resource has been loaded: a file over the limit has
// already crossed the network. When its length is declared, nothing is read and the real transfer is counted.
var declared = DeclaredLength(resource);
if (options?.MaxBytes is { } limit && declared > limit)
{
await CloseQuietlyAsync(handle).ConfigureAwait(false);
return new FetchResult(FetchOutcome.TooLarge, 0, status, "Il file supera la dimensione massima ammessa.") { TransferredBytes = declared };
}
long written = 0;
try
{
@@ -122,7 +131,10 @@ public sealed class BrowserFileFetcher : IFileFetcher
var allowed = (int)Math.Max(0, max - written);
await destination.WriteAsync(bytes.AsMemory(0, allowed), ct).ConfigureAwait(false);
written += allowed;
return new FetchResult(FetchOutcome.TooLarge, written, status, "Il file supera la dimensione massima ammessa.");
return new FetchResult(FetchOutcome.TooLarge, written, status, "Il file supera la dimensione massima ammessa.")
{
TransferredBytes = declared > written ? declared : null,
};
}
await destination.WriteAsync(bytes, ct).ConfigureAwait(false);
@@ -147,6 +159,27 @@ public sealed class BrowserFileFetcher : IFileFetcher
: new FetchResult(FetchOutcome.Completed, written, status, null);
}
/// <summary>The Content-Length the response declared (header names are case-insensitive), or null.</summary>
private static long? DeclaredLength(JsonElement resource)
{
if (!resource.TryGetProperty("headers", out var headers) || headers.ValueKind != JsonValueKind.Object)
{
return null;
}
foreach (var header in headers.EnumerateObject())
{
if (string.Equals(header.Name, "content-length", StringComparison.OrdinalIgnoreCase)
&& header.Value.ValueKind == JsonValueKind.String
&& long.TryParse(header.Value.GetString(), System.Globalization.NumberStyles.None, System.Globalization.CultureInfo.InvariantCulture, out var length))
{
return length;
}
}
return null;
}
private async Task CloseQuietlyAsync(string handle)
{
try
@@ -162,7 +162,8 @@ public sealed class CollectionPipeline : IAsyncDisposable
options.DataBudget,
options.Clock,
options.Random,
new DownloadOptions { StagingFolder = options.StagingFolder });
new DownloadOptions { StagingFolder = options.StagingFolder },
signals);
var pipeline = new CollectionPipeline(tap, signals, capture, driver, runner, downloads, siteMap, targets);
pipeline._subscriptions.Add(tap.AddObserver(signals));