Skip to content

Commit

Permalink
lib/fetcher-soup: Map more SoupStatus codes to known GIOErrors
Browse files Browse the repository at this point in the history
This allows the retry code in ostree-repo-pull.c to recover from (for
example) timeouts at the libsoup layer in the stack, as well as from the
GSocket layer in the stack.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1594
Approved by: jlebon
  • Loading branch information
pwithnall authored and rh-atomic-bot committed May 30, 2018
1 parent 9380553 commit 224f3cd
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/libostree/ostree-fetcher-soup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1072,11 +1072,28 @@ on_request_sent (GObject *object,
GIOErrorEnum code;
switch (msg->status_code)
{
case 404:
case 403:
case 410:
case SOUP_STATUS_NOT_FOUND:
case SOUP_STATUS_FORBIDDEN:
case SOUP_STATUS_GONE:
code = G_IO_ERROR_NOT_FOUND;
break;
case SOUP_STATUS_CANCELLED:
code = G_IO_ERROR_CANCELLED;
break;
case SOUP_STATUS_REQUEST_TIMEOUT:
code = G_IO_ERROR_TIMED_OUT;
break;
case SOUP_STATUS_CANT_RESOLVE:
case SOUP_STATUS_CANT_CONNECT:
code = G_IO_ERROR_HOST_NOT_FOUND;
break;
case SOUP_STATUS_IO_ERROR:
#if !GLIB_CHECK_VERSION(2, 44, 0)
code = G_IO_ERROR_BROKEN_PIPE;
#else
code = G_IO_ERROR_CONNECTION_CLOSED;
#endif
break;
default:
code = G_IO_ERROR_FAILED;
}
Expand Down

0 comments on commit 224f3cd

Please sign in to comment.