req = g_task_get_task_data (task);
+ gboolean retry_all = (!is_file && req->fetcher->opt_retry_all);
+
if (req->caught_write_error)
g_task_return_error (task, g_steal_pointer (&req->caught_write_error));
else if (curlres != CURLE_OK)
/* When it is not a file, we want to retry the request.
* We accomplish that by using G_IO_ERROR_TIMED_OUT.
*/
- gboolean opt_retry_all = req->fetcher->opt_retry_all;
- int g_io_error_code
- = (is_file || !opt_retry_all) ? G_IO_ERROR_FAILED : G_IO_ERROR_TIMED_OUT;
- g_task_return_new_error (task, G_IO_ERROR, g_io_error_code,
- "While fetching %s: [%u] %s", eff_url, curlres,
- curl_easy_strerror (curlres));
+ g_task_return_new_error (
+ task, G_IO_ERROR, retry_all ? G_IO_ERROR_TIMED_OUT : G_IO_ERROR,
+ "While fetching %s: [%u] %s", eff_url, curlres, curl_easy_strerror (curlres));
_ostree_fetcher_journal_failure (req->fetcher->remote_name, eff_url,
curl_easy_strerror (curlres));
}
if (!is_file && !(response >= 200 && response < 300) && response != 304)
{
- GIOErrorEnum giocode = _ostree_fetcher_http_status_code_to_io_error (response);
+ GIOErrorEnum giocode
+ = _ostree_fetcher_http_status_code_to_io_error (response, retry_all);
if (req->idx + 1 == req->mirrorlist->len)
{
- g_autofree char *response_msg
- = g_strdup_printf ("Server returned HTTP %lu", response);
+ g_autofree char *response_msg = g_strdup_printf (
+ "While fetching %s: Server returned HTTP %lu", eff_url, response);
g_task_return_new_error (task, G_IO_ERROR, giocode, "%s", response_msg);
if (req->fetcher->remote_name
&& !((req->flags & OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT) > 0
{
g_autofree char *uristring
= g_uri_to_string (soup_message_get_uri (request->message));
- GIOErrorEnum code = _ostree_fetcher_http_status_code_to_io_error (status);
+ GIOErrorEnum code = _ostree_fetcher_http_status_code_to_io_error (status, FALSE);
{
g_autofree char *errmsg = g_strdup_printf ("Server returned status %u: %s", status,
soup_status_get_phrase (status));
* a #GIOErrorEnum. This will return %G_IO_ERROR_FAILED if the status code is
* unknown or otherwise unhandled. */
GIOErrorEnum
-_ostree_fetcher_http_status_code_to_io_error (guint status_code)
+_ostree_fetcher_http_status_code_to_io_error (guint status_code, gboolean should_retry)
{
switch (status_code)
{
case 408: /* SOUP_STATUS_REQUEST_TIMEOUT */
return G_IO_ERROR_TIMED_OUT;
case 500: /* SOUP_STATUS_INTERNAL_SERVER_ERROR */
- return G_IO_ERROR_BUSY;
+ /* retries are always mapped to timeouts, see similar logic in the curl error handling */
+ return should_retry ? G_IO_ERROR_TIMED_OUT : G_IO_ERROR_BUSY;
default:
- return G_IO_ERROR_FAILED;
+ return should_retry ? G_IO_ERROR_TIMED_OUT : G_IO_ERROR_FAILED;
}
}