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:
Philip Withnall authored and Atomic Bot committed 2018-05-30 16:23:57 +00:00
1 parent 78f40136db
commit 197644c406
4 files changed
+26 -22

No files matched your search

+4 -9
View File
@@ -1070,19 +1070,13 @@ on_request_sent (GObject *object,
soup_uri_to_string (soup_request_get_uri (pending->request), FALSE);
GIOErrorEnum code;
switch (msg->status_code)
{
case SOUP_STATUS_NOT_FOUND:
case SOUP_STATUS_FORBIDDEN:
case SOUP_STATUS_GONE:
code = G_IO_ERROR_NOT_FOUND;
break;
/* These statuses are internal to libsoup, and not standard HTTP ones: */
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;
@@ -1095,7 +1089,8 @@ on_request_sent (GObject *object,
#endif
break;
default:
code = G_IO_ERROR_FAILED;
code = _ostree_fetcher_http_status_code_to_io_error (msg->status_code);
break;
}
{