From f78bec43d6509dac7deb3608dd37ea24bae2e953 Mon Sep 17 00:00:00 2001 From: glax Date: Thu, 19 Oct 2023 12:59:20 +0200 Subject: [PATCH] Fix an issue where a request-timeout would cause a restartloop. --- Tranga/MangaConnectors/HttpDownloadClient.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Tranga/MangaConnectors/HttpDownloadClient.cs b/Tranga/MangaConnectors/HttpDownloadClient.cs index da5b795..8834397 100644 --- a/Tranga/MangaConnectors/HttpDownloadClient.cs +++ b/Tranga/MangaConnectors/HttpDownloadClient.cs @@ -1,4 +1,5 @@ -using System.Net.Http.Headers; +using System.Net; +using System.Net.Http.Headers; using HtmlAgilityPack; namespace Tranga.MangaConnectors; @@ -32,7 +33,15 @@ internal class HttpDownloadClient : DownloadClient if (referrer is not null) requestMessage.Headers.Referrer = new Uri(referrer); //Log($"Requesting {requestType} {url}"); - response = Client.Send(requestMessage); + try + { + response = Client.Send(requestMessage); + } + catch (TaskCanceledException e) + { + Log($"Request timed out.\n\r{e}"); + return new RequestResult(HttpStatusCode.RequestTimeout, null, Stream.Null); + } } if (!response.IsSuccessStatusCode)