[librest] Add rest_proxy_add_soup_feature()
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librest] Add rest_proxy_add_soup_feature()
- Date: Tue, 2 Sep 2014 08:20:57 +0000 (UTC)
commit 68d90e9e315d279aebe04d6b1177e57c075b8f72
Author: Christophe Fergeau <cfergeau redhat com>
Date: Wed Dec 11 15:27:23 2013 +0100
Add rest_proxy_add_soup_feature()
This function can be helpful if one wants more control over libsoup
features than what librest simple API provide. For example, to get full
access to libsoup cookie API (say to be able to add arbitrary cookies to
the soup session), one can do:
RestProxy *proxy = g_object_new(REST_TYPE_PROXY,
"url-format", url,
"disable-cookies", TRUE,
NULL);
SoupSessionFeature *cookie_jar = SOUP_SESSION_FEATURE(soup_cookie_jar_new ());
rest_proxy_add_soup_feature(proxy, cookie_jar);
It's then possible to use all the soup_cookie_* methods to deal with
cookies.
https://bugzilla.gnome.org/show_bug.cgi?id=728340
docs/reference/rest/rest-sections.txt | 1 +
rest/rest-proxy.c | 36 +++++++++++++++++++++++++++++++++
rest/rest-proxy.h | 4 +++
3 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/rest/rest-sections.txt b/docs/reference/rest/rest-sections.txt
index 66950fe..2395bb7 100644
--- a/docs/reference/rest/rest-sections.txt
+++ b/docs/reference/rest/rest-sections.txt
@@ -116,6 +116,7 @@ rest_proxy_bind
rest_proxy_bind_valist
rest_proxy_set_user_agent
rest_proxy_get_user_agent
+rest_proxy_add_soup_feature
rest_proxy_new_call
rest_proxy_simple_run
rest_proxy_simple_run_valist
diff --git a/rest/rest-proxy.c b/rest/rest-proxy.c
index 44f56bf..81d487d 100644
--- a/rest/rest-proxy.c
+++ b/rest/rest-proxy.c
@@ -566,6 +566,42 @@ rest_proxy_get_user_agent (RestProxy *proxy)
return priv->user_agent;
}
+/**
+ * rest_proxy_add_soup_feature:
+ * @proxy: The #RestProxy
+ * @feature: A #SoupSessionFeature
+ *
+ * This method can be used to add specific features to the #SoupSession objects
+ * that are used by librest for its HTTP connections. For example, if one needs
+ * extensive control over the cookies which are used for the REST HTTP
+ * communication, it's possible to get full access to libsoup cookie API by
+ * using
+ *
+ * <programlisting>
+ * RestProxy *proxy = g_object_new(REST_TYPE_PROXY,
+ * "url-format", url,
+ * "disable-cookies", TRUE,
+ * NULL);
+ * SoupSessionFeature *cookie_jar = SOUP_SESSION_FEATURE(soup_cookie_jar_new ());
+ * rest_proxy_add_soup_feature(proxy, cookie_jar);
+ * </programlisting>
+ *
+ * Since: 0.7.92
+ */
+void
+rest_proxy_add_soup_feature (RestProxy *proxy, SoupSessionFeature *feature)
+{
+ RestProxyPrivate *priv;
+
+ g_return_if_fail (REST_IS_PROXY(proxy));
+ priv = GET_PRIVATE (proxy);
+ g_return_if_fail (priv->session != NULL);
+ g_return_if_fail (priv->session_sync != NULL);
+
+ soup_session_add_feature (priv->session, feature);
+ soup_session_add_feature (priv->session_sync, feature);
+}
+
static RestProxyCall *
_rest_proxy_new_call (RestProxy *proxy)
{
diff --git a/rest/rest-proxy.h b/rest/rest-proxy.h
index 8c3dd68..d341403 100644
--- a/rest/rest-proxy.h
+++ b/rest/rest-proxy.h
@@ -24,6 +24,7 @@
#define _REST_PROXY
#include <glib-object.h>
+#include <libsoup/soup-session-feature.h>
#include <rest/rest-proxy-auth.h>
#include <rest/rest-proxy-call.h>
@@ -196,6 +197,9 @@ void rest_proxy_set_user_agent (RestProxy *proxy, const char *user_agent);
const gchar *rest_proxy_get_user_agent (RestProxy *proxy);
+void rest_proxy_add_soup_feature (RestProxy *proxy,
+ SoupSessionFeature *feature);
+
RestProxyCall *rest_proxy_new_call (RestProxy *proxy);
G_GNUC_NULL_TERMINATED
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]