summaryrefslogtreecommitdiff
path: root/rest/rest-proxy-call.c
diff options
context:
space:
mode:
Diffstat (limited to 'rest/rest-proxy-call.c')
-rw-r--r--rest/rest-proxy-call.c60
1 files changed, 47 insertions, 13 deletions
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index e94bba4..bfe580b 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -742,23 +742,13 @@ set_header (gpointer key, gpointer value, gpointer user_data)
soup_message_headers_replace (headers, name, value);
}
-static SoupMessage *
-prepare_message (RestProxyCall *call, GError **error_out)
+static gboolean
+set_url (RestProxyCall *call)
{
RestProxyCallPrivate *priv;
- RestProxyCallClass *call_class;
- const gchar *bound_url, *user_agent;
- SoupMessage *message;
- GError *error = NULL;
+ const gchar *bound_url;
priv = GET_PRIVATE (call);
- call_class = REST_PROXY_CALL_GET_CLASS (call);
-
- /* Emit a warning if the caller is re-using RestProxyCall objects */
- if (priv->url)
- {
- g_warning (G_STRLOC ": re-use of RestProxyCall %p, don't do this", call);
- }
bound_url =_rest_proxy_get_bound_url (priv->proxy);
@@ -768,6 +758,8 @@ prepare_message (RestProxyCall *call, GError **error_out)
return FALSE;
}
+ g_free (priv->url);
+
/* FIXME: Perhaps excessive memory duplication */
if (priv->function)
{
@@ -782,6 +774,27 @@ prepare_message (RestProxyCall *call, GError **error_out)
priv->url = g_strdup (bound_url);
}
+ return TRUE;
+}
+
+static SoupMessage *
+prepare_message (RestProxyCall *call, GError **error_out)
+{
+ RestProxyCallPrivate *priv;
+ RestProxyCallClass *call_class;
+ const gchar *user_agent;
+ SoupMessage *message;
+ GError *error = NULL;
+
+ priv = GET_PRIVATE (call);
+ call_class = REST_PROXY_CALL_GET_CLASS (call);
+
+ /* Emit a warning if the caller is re-using RestProxyCall objects */
+ if (priv->url)
+ {
+ g_warning (G_STRLOC ": re-use of RestProxyCall %p, don't do this", call);
+ }
+
/* Allow an overrideable prepare function that is called before every
* invocation so subclasses can do magic
*/
@@ -806,6 +819,16 @@ prepare_message (RestProxyCall *call, GError **error_out)
return NULL;
}
+ /* Reset priv->url as the serialize_params vcall may have called
+ * rest_proxy_call_set_function()
+ */
+ if (!set_url (call))
+ {
+ g_free (content);
+ g_free (content_type);
+ return NULL;
+ }
+
message = soup_message_new (priv->method, priv->url);
if (message == NULL) {
g_free (content);
@@ -823,6 +846,11 @@ prepare_message (RestProxyCall *call, GError **error_out)
} else if (rest_params_are_strings (priv->params)) {
GHashTable *hash;
+ if (!set_url (call))
+ {
+ return NULL;
+ }
+
hash = rest_params_as_string_hash_table (priv->params);
message = soup_form_request_new_from_hash (priv->method,
@@ -860,6 +888,12 @@ prepare_message (RestProxyCall *call, GError **error_out)
}
}
+ if (!set_url (call))
+ {
+ soup_multipart_free (mp);
+ return NULL;
+ }
+
message = soup_form_request_new_from_multipart (priv->url, mp);
soup_multipart_free (mp);