From c1f6a02fa039c0fb681b3cc963f9c3dc7e6cfb12 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Wed, 29 Jan 2025 18:10:13 +0100 Subject: [PATCH] NewsDownloader: deal with 404 and other error statuses better (#13165) May be relevant to #9363. In any case one of the most typical kind of failures wasn't treated properly, so a 404 would mess up everything instead of popping up a dialog. --- plugins/newsdownloader.koplugin/epubdownloadbackend.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/newsdownloader.koplugin/epubdownloadbackend.lua b/plugins/newsdownloader.koplugin/epubdownloadbackend.lua index f706e6eaa..5cc8c654c 100644 --- a/plugins/newsdownloader.koplugin/epubdownloadbackend.lua +++ b/plugins/newsdownloader.koplugin/epubdownloadbackend.lua @@ -191,6 +191,10 @@ local function getUrlContent(url, cookies, timeout, maxtime, redirectCount) logger.warn("request interrupted:", status or code) return false, code end + if code >= 400 and code < 500 then + logger.warn("HTTP error:", status or code) + return false, status or code + end if headers == nil then logger.warn("No HTTP headers:", status or code or "network unreachable") return false, "Network or remote server unavailable" @@ -210,7 +214,7 @@ local function getUrlContent(url, cookies, timeout, maxtime, redirectCount) error("EpubDownloadBackend: Don't know how to handle HTTP response status:", status or code) end logger.warn("HTTP status not okay:", status or code) - return false, "Remote server error or unavailable" + return false, status or code end if headers and headers["content-length"] then -- Check we really got the announced content size