Catch Stream closed
Some checks failed
Docker Image CI / build (push) Has been cancelled

This commit is contained in:
Glax 2025-04-01 18:24:25 +02:00
parent 15ced9aed8
commit 99a3f2614d
2 changed files with 14 additions and 3 deletions

View File

@ -1,14 +1,16 @@
using System.Net; using System.Net;
using API.Schema; using log4net;
namespace API.MangaDownloadClients; namespace API.MangaDownloadClients;
internal abstract class DownloadClient internal abstract class DownloadClient
{ {
private readonly Dictionary<RequestType, DateTime> _lastExecutedRateLimit; private readonly Dictionary<RequestType, DateTime> _lastExecutedRateLimit;
protected ILog Log { get; init; }
protected DownloadClient() protected DownloadClient()
{ {
this.Log = LogManager.GetLogger(GetType());
this._lastExecutedRateLimit = new(); this._lastExecutedRateLimit = new();
} }

View File

@ -48,8 +48,17 @@ internal class HttpDownloadClient : DownloadClient
{ {
return new RequestResult(response.StatusCode, null, Stream.Null); return new RequestResult(response.StatusCode, null, Stream.Null);
} }
Stream stream = response.Content.ReadAsStream(); Stream stream;
try
{
stream = response.Content.ReadAsStream();
}
catch (Exception e)
{
Log.Error(e);
return new RequestResult(HttpStatusCode.InternalServerError, null, Stream.Null);
}
HtmlDocument? document = null; HtmlDocument? document = null;