[gvfs] Unify error conversion in http and dav backends
- From: Ross Lagerwall <rossl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] Unify error conversion in http and dav backends
- Date: Fri, 11 Apr 2014 16:52:30 +0000 (UTC)
commit 208cf642ca1a070e5695c23afecea40740052a75
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Sat Apr 5 20:17:26 2014 +0100
Unify error conversion in http and dav backends
Have a single function which converts libsoup error codes to gio error
codes rather than one in each backend.
https://bugzilla.gnome.org/show_bug.cgi?id=536305
daemon/gvfsbackenddav.c | 34 +++-------------------------------
daemon/gvfsbackendhttp.c | 10 +++++++++-
daemon/gvfsbackendhttp.h | 2 +-
3 files changed, 13 insertions(+), 33 deletions(-)
---
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index 8c92d18..694c7a6 100644
--- a/daemon/gvfsbackenddav.c
+++ b/daemon/gvfsbackenddav.c
@@ -637,36 +637,6 @@ xml_node_iter_get_current (xmlNodeIter *iter)
return iter->cur_node;
}
-static gint
-http_to_gio_error(guint status_code)
-{
- switch (status_code)
- {
- case SOUP_STATUS_NOT_FOUND:
- return G_IO_ERROR_NOT_FOUND;
- break;
- case SOUP_STATUS_UNAUTHORIZED:
- case SOUP_STATUS_PAYMENT_REQUIRED:
- case SOUP_STATUS_FORBIDDEN:
- return G_IO_ERROR_PERMISSION_DENIED;
- break;
- case SOUP_STATUS_REQUEST_TIMEOUT:
- return G_IO_ERROR_TIMED_OUT;
- break;
- case SOUP_STATUS_CANT_RESOLVE:
- return G_IO_ERROR_HOST_NOT_FOUND;
- break;
- case SOUP_STATUS_NOT_IMPLEMENTED:
- return G_IO_ERROR_NOT_SUPPORTED;
- break;
- case SOUP_STATUS_INSUFFICIENT_STORAGE:
- return G_IO_ERROR_NO_SPACE;
- break;
- }
-
- return G_IO_ERROR_FAILED;
-}
-
static xmlDocPtr
parse_xml (SoupMessage *msg,
xmlNodePtr *root,
@@ -677,7 +647,9 @@ parse_xml (SoupMessage *msg,
if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
{
- g_set_error (error, G_IO_ERROR, http_to_gio_error (msg->status_code),
+ g_set_error (error,
+ G_IO_ERROR,
+ http_error_code_from_status (msg->status_code),
_("HTTP Error: %s"), msg->reason_phrase);
return NULL;
}
diff --git a/daemon/gvfsbackendhttp.c b/daemon/gvfsbackendhttp.c
index f58a5c8..963c78b 100644
--- a/daemon/gvfsbackendhttp.c
+++ b/daemon/gvfsbackendhttp.c
@@ -206,7 +206,7 @@ http_uri_get_basename (const char *uri_str)
return decoded;
}
-guint
+int
http_error_code_from_status (guint status)
{
switch (status) {
@@ -228,7 +228,15 @@ http_error_code_from_status (guint status)
return G_IO_ERROR_NOT_FOUND;
case SOUP_STATUS_GATEWAY_TIMEOUT:
+ case SOUP_STATUS_REQUEST_TIMEOUT:
return G_IO_ERROR_TIMED_OUT;
+
+ case SOUP_STATUS_NOT_IMPLEMENTED:
+ return G_IO_ERROR_NOT_SUPPORTED;
+
+ case SOUP_STATUS_INSUFFICIENT_STORAGE:
+ return G_IO_ERROR_NO_SPACE;
+
}
return G_IO_ERROR_FAILED;
diff --git a/daemon/gvfsbackendhttp.h b/daemon/gvfsbackendhttp.h
index a380074..8ff943c 100644
--- a/daemon/gvfsbackendhttp.h
+++ b/daemon/gvfsbackendhttp.h
@@ -61,7 +61,7 @@ char * http_uri_get_basename (const char *uri_str);
char * http_path_get_basename (const char *path_str);
-guint http_error_code_from_status (guint status);
+int http_error_code_from_status (guint status);
SoupURI * http_backend_get_mount_base (GVfsBackend *backend);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]