summaryrefslogtreecommitdiff
path: root/rest/rest-proxy-call.c
diff options
context:
space:
mode:
authorMichal Mhr <michal.mhr@gmail.com>2011-04-13 16:41:57 +0100
committerRoss Burton <ross@linux.intel.com>2011-04-13 16:46:19 +0100
commit9545fef5381120b77d7c5341a95733228b641c0f (patch)
tree670c5877a3157def61304bcb08278e1ed93f8efb /rest/rest-proxy-call.c
parent77606ecf0c0430d38a07e47b6e4be2789cc5e928 (diff)
downloadlibrest-9545fef5381120b77d7c5341a95733228b641c0f.tar.gz
proxy-call: Allow customisation of data serialization (BMC#13746)
Diffstat (limited to 'rest/rest-proxy-call.c')
-rw-r--r--rest/rest-proxy-call.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index 22272f8..6ffa56c 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -745,7 +745,24 @@ prepare_message (RestProxyCall *call, GError **error_out)
}
}
- if (rest_params_are_strings (priv->params)) {
+ if (call_class->serialize_params) {
+ gchar *content;
+ gchar *content_type;
+ gsize content_len;
+
+ if (!call_class->serialize_params (call, &content_type,
+ &content, &content_len, &error))
+ {
+ g_propagate_error (error_out, error);
+ return NULL;
+ }
+
+ message = soup_message_new (priv->method, priv->url);
+ soup_message_set_request (message, content_type,
+ SOUP_MEMORY_TAKE, content, content_len);
+
+ g_free (content_type);
+ } else if (rest_params_are_strings (priv->params)) {
GHashTable *hash;
hash = rest_params_as_string_hash_table (priv->params);
@@ -1228,3 +1245,36 @@ rest_proxy_call_get_status_message (RestProxyCall *call)
return priv->status_message;
}
+
+/**
+ * rest_proxy_call_serialize_params:
+ * @call: The #RestProxyCall
+ * @content_type: (out): Content type of the payload
+ * @content: (out): The payload
+ * @content_len: (out): Length of the payload data
+ * @error: a #GError, or %NULL
+ *
+ * Invoker for a virtual method to serialize the parameters for this
+ * #RestProxyCall.
+ *
+ * Returns: TRUE if the serialization was successful, FALSE otherwise.
+ */
+gboolean
+rest_proxy_call_serialize_params (RestProxyCall *call,
+ gchar **content_type,
+ gchar **content,
+ gsize *content_len,
+ GError **error)
+{
+ RestProxyCallClass *call_class;
+
+ call_class = REST_PROXY_CALL_GET_CLASS (call);
+
+ if (call_class->serialize_params)
+ {
+ return call_class->serialize_params (call, content_type,
+ content, content_len, error);
+ }
+
+ return FALSE;
+}