Skip to content

Commit 192af9f

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 227a2f3 commit 192af9f

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
@@ -971,9 +971,16 @@ static gpointer download_thread(gpointer data)
971971
resume_from, &sha1sum, &speed, &error))
972972
break;
973973

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

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

0 commit comments

Comments
 (0)