Skip to content

Commit 53e0e01

Browse files
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 <bst@pengutronix.de>
1 parent f7c233c commit 53e0e01

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/hawkbit-client.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,9 +969,16 @@ static gpointer download_thread(gpointer data)
969969
resume_from, &sha1sum, &speed, &error))
970970
break;
971971

972+
// resume download under certain conditions
972973
for (const gint *code = &resumable_codes[0]; *code; code++)
973974
resumable |= g_error_matches(error, RHU_HAWKBIT_CLIENT_CURL_ERROR, *code);
974975

976+
// but do not resume download on persistent HTTP server errors
977+
if (error->domain == RHU_HAWKBIT_CLIENT_HTTP_ERROR &&
978+
error->code >= 400 && error->code < 500 &&
979+
error->code != 408 && error->code != 429)
980+
resumable = FALSE;
981+
975982
if (!hawkbit_config->resume_downloads || !resumable) {
976983
g_prefix_error(&error, "Download failed: ");
977984
goto report_err;

0 commit comments

Comments
 (0)