Better Debugging for HttpDownloadClient

This commit is contained in:
2025-06-17 18:52:27 +02:00
parent 07b260dea6
commit b5411e9c6c

View File

@ -30,6 +30,15 @@ internal class HttpDownloadClient : DownloadClient
} }
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{
Log.Debug($"Request returned status code {(int)response.StatusCode} {response.StatusCode}");
if (response.Headers.Server.Any(s =>
(s.Product?.Name ?? "").Contains("cloudflare", StringComparison.InvariantCultureIgnoreCase)))
{
Log.Debug("Retrying with FlareSolverr!");
return new FlareSolverrDownloadClient().MakeRequestInternal(url, referrer, clickButton);
}
else
{ {
Log.Debug($"Request returned status code {(int)response.StatusCode} {response.StatusCode}:\n" + Log.Debug($"Request returned status code {(int)response.StatusCode} {response.StatusCode}:\n" +
$"=====\n" + $"=====\n" +
@ -43,7 +52,7 @@ internal class HttpDownloadClient : DownloadClient
$"{response.Version}\n" + $"{response.Version}\n" +
$"Headers:\n\t{string.Join("\n\t", response.Headers.Select(h => $"{h.Key}: <{string.Join(">, <", h.Value)}"))}>\n" + $"Headers:\n\t{string.Join("\n\t", response.Headers.Select(h => $"{h.Key}: <{string.Join(">, <", h.Value)}"))}>\n" +
$"{response.Content.ReadAsStringAsync().Result}"); $"{response.Content.ReadAsStringAsync().Result}");
return new FlareSolverrDownloadClient().MakeRequestInternal(url, referrer, clickButton); }
} }
Stream stream; Stream stream;