[libgovirt] Tweak use of OvirtResourceRestCall for !PUT requests



commit 758601a99294dff96e8ebc3ce0d54c977312abd1
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Tue Apr 29 11:57:54 2014 +0200

    Tweak use of OvirtResourceRestCall for !PUT requests
    
    It's more appropriate to use this when doing a GET on a resource or
    collection rather than using OvirtActionRestCall. However, unless we are
    doing a PUT, we don't need to send a serialized version of the object we
    are handling.

 govirt/ovirt-resource-rest-call.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/govirt/ovirt-resource-rest-call.c b/govirt/ovirt-resource-rest-call.c
index 23dfd1e..41ac0f4 100644
--- a/govirt/ovirt-resource-rest-call.c
+++ b/govirt/ovirt-resource-rest-call.c
@@ -127,8 +127,14 @@ static gboolean ovirt_resource_rest_call_class_serialize_params(RestProxyCall *c
     self = OVIRT_RESOURCE_REST_CALL(call);
 
     *content_type = g_strdup("application/xml");
-    *content = ovirt_resource_to_xml(self->priv->resource);
-    *content_len = strlen(*content);
+    if (g_strcmp0(rest_proxy_call_get_method(call), "PUT") == 0) {
+        g_return_val_if_fail(self->priv->resource != NULL, FALSE);
+        *content = ovirt_resource_to_xml(self->priv->resource);
+        *content_len = strlen(*content);
+    } else {
+        *content = NULL;
+        *content_len = 0;
+    }
 
     params = rest_proxy_call_get_params(call);
     if (!rest_params_are_strings(params)) {


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