From 192af9f322c05e5d094ff0a5a18c5816ed73cd0a Mon Sep 17 00:00:00 2001 From: Bastian Krause Date: Wed, 15 Apr 2026 12:27:00 +0200 Subject: [PATCH] hawkbit-client: do not resume downloads for persistent server errors Most 4xx HTTP status codes indicate that retrying the request unmodified is not going to lead to success. Exceptions are "408 Request Timeout" and "429 Too Many Requests". So do not try to resume downloads under these conditions and report an error to hawkBit immediately. Signed-off-by: Bastian Krause --- src/hawkbit-client.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hawkbit-client.c b/src/hawkbit-client.c index e39997f..ce63110 100644 --- a/src/hawkbit-client.c +++ b/src/hawkbit-client.c @@ -971,9 +971,16 @@ static gpointer download_thread(gpointer data) resume_from, &sha1sum, &speed, &error)) break; + // resume download under certain conditions for (const gint *code = &resumable_codes[0]; *code; code++) resumable |= g_error_matches(error, RHU_HAWKBIT_CLIENT_CURL_ERROR, *code); + // but do not resume download on persistent HTTP server errors + if (error->domain == RHU_HAWKBIT_CLIENT_HTTP_ERROR && + error->code >= 400 && error->code < 500 && + error->code != 408 && error->code != 429) + resumable = FALSE; + if (!hawkbit_config->resume_downloads || !resumable) { g_prefix_error(&error, "Download failed: "); goto report_err;