[libgovirt] Strip /api/ when doing sync REST calls as well



commit 395a592721afdf5928a543ee76cc1ff078a274f5
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Wed Aug 21 18:03:17 2013 +0200

    Strip /api/ when doing sync REST calls as well
    
    Relative hrefs stored in oVirt XML data always start with /api/,
    which we don't expect when doing our calls. This was stripped
    when doing async calls, but not when doing sync calls. This commit
    makes sure it's done in both code paths.

 govirt/ovirt-proxy.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
index 5da9544..540a14e 100644
--- a/govirt/ovirt-proxy.c
+++ b/govirt/ovirt-proxy.c
@@ -178,6 +178,16 @@ gboolean ovirt_proxy_fetch_vms(OvirtProxy *proxy, GError **error)
     return TRUE;
 }
 
+static const char *ovirt_rest_strip_api_base_dir(const char *path)
+{
+    if (g_str_has_prefix(path, OVIRT_API_BASE_DIR)) {
+        g_debug("stripping %s from %s", OVIRT_API_BASE_DIR, path);
+        path += strlen(OVIRT_API_BASE_DIR);
+    }
+
+    return path;
+}
+
 RestXmlNode *ovirt_proxy_get_collection_xml(OvirtProxy *proxy,
                                             const char *href,
                                             GError **error)
@@ -188,6 +198,7 @@ RestXmlNode *ovirt_proxy_get_collection_xml(OvirtProxy *proxy,
     g_return_val_if_fail(OVIRT_IS_PROXY(proxy), NULL);
 
     call = REST_PROXY_CALL(ovirt_rest_call_new(REST_PROXY(proxy)));
+    href = ovirt_rest_strip_api_base_dir(href);
     rest_proxy_call_set_function(call, href);
     rest_proxy_call_add_header(call, "All-Content", "true");
 
@@ -268,16 +279,6 @@ call_async_cb(RestProxyCall *call, const GError *error,
     ovirt_proxy_call_async_data_free(data);
 }
 
-static const char *ovirt_rest_strip_api_base_dir(const char *path)
-{
-    if (g_str_has_prefix(path, OVIRT_API_BASE_DIR)) {
-        g_debug("stripping %s from %s", OVIRT_API_BASE_DIR, path);
-        path += strlen(OVIRT_API_BASE_DIR);
-    }
-
-    return path;
-}
-
 void ovirt_rest_call_async(OvirtProxy *proxy,
                            const char *method,
                            const char *href,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]