lib/fetcher: Factor out HTTP status code handling from soup and curl
Use the same G_IO_ERROR_* values for HTTP status codes in both fetchers. The libsoup fetcher still handles a few more internal error codes than the libcurl one; this could be built on in future. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1594 Approved by: jlebon
This commit is contained in:
1 parent
78f40136db
commit
197644c406
4 files changed
+26
-22
No files matched your search
@@ -218,3 +218,22 @@ _ostree_fetcher_should_retry_request (const GError *error,
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Convert a HTTP status code representing an error from libsoup or libcurl to
|
||||
* a #GIOError. This will return %G_IO_ERROR_FAILED if the status code is
|
||||
* unknown or otherwise unhandled. */
|
||||
GIOError
|
||||
_ostree_fetcher_http_status_code_to_io_error (guint status_code)
|
||||
{
|
||||
switch (status_code)
|
||||
{
|
||||
case 403: /* SOUP_STATUS_FORBIDDEN */
|
||||
case 404: /* SOUP_STATUS_NOT_FOUND */
|
||||
case 410: /* SOUP_STATUS_GONE */
|
||||
return G_IO_ERROR_NOT_FOUND;
|
||||
case 408: /* SOUP_STATUS_REQUEST_TIMEOUT */
|
||||
return G_IO_ERROR_TIMED_OUT;
|
||||
default:
|
||||
return G_IO_ERROR_FAILED;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user