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.
This commit is contained in:
Frans de Jonge
2025-01-29 18:10:13 +01:00
committed by GitHub
parent 08b9fd9aa7
commit c1f6a02fa0

View File

@@ -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