[libsoup/wip/tingping/request-block-cookies] Add API to block cookies per-request
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/tingping/request-block-cookies] Add API to block cookies per-request
- Date: Tue, 5 Feb 2019 15:38:23 +0000 (UTC)
commit 3a7abb1b8b60ef70fcec2fddf51bb481cec2248e
Author: Patrick Griffis <tingping tingping se>
Date: Tue Feb 5 10:35:55 2019 -0500
Add API to block cookies per-request
This will be used by WebKit
libsoup/soup-cookie-jar.c | 12 ++++++++++++
libsoup/soup-request-http.c | 18 ++++++++++++++++++
libsoup/soup-request-http.h | 6 ++++++
3 files changed, 36 insertions(+)
---
diff --git a/libsoup/soup-cookie-jar.c b/libsoup/soup-cookie-jar.c
index b2b78909..6760907c 100644
--- a/libsoup/soup-cookie-jar.c
+++ b/libsoup/soup-cookie-jar.c
@@ -668,10 +668,15 @@ process_set_cookie_header (SoupMessage *msg, gpointer user_data)
SoupCookieJar *jar = user_data;
SoupCookieJarPrivate *priv = soup_cookie_jar_get_instance_private (jar);
GSList *new_cookies, *nc;
+ SoupRequest *request;
if (priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_NEVER)
return;
+ request = soup_message_get_soup_request (msg);
+ if (SOUP_IS_REQUEST_HTTP (request) && soup_request_http_get_block_cookies (SOUP_REQUEST_HTTP
(request)))
+ return;
+
new_cookies = soup_cookies_from_response (msg);
for (nc = new_cookies; nc; nc = nc->next) {
SoupURI *first_party = soup_message_get_first_party (msg);
@@ -691,6 +696,13 @@ msg_starting_cb (SoupMessage *msg, gpointer feature)
{
SoupCookieJar *jar = SOUP_COOKIE_JAR (feature);
char *cookies;
+ SoupRequest *request;
+
+ request = soup_message_get_soup_request (msg);
+ if (SOUP_IS_REQUEST_HTTP (request) && soup_request_http_get_block_cookies (SOUP_REQUEST_HTTP
(request)) {
+ soup_message_headers_remove (msg->request_headers, "Cookie");
+ return;
+ }
cookies = soup_cookie_jar_get_cookies (jar, soup_message_get_uri (msg), TRUE);
if (cookies) {
diff --git a/libsoup/soup-request-http.c b/libsoup/soup-request-http.c
index 285f59d7..8800a02c 100644
--- a/libsoup/soup-request-http.c
+++ b/libsoup/soup-request-http.c
@@ -47,6 +47,7 @@
struct _SoupRequestHTTPPrivate {
SoupMessage *msg;
char *content_type;
+ gboolean block_cookies;
};
G_DEFINE_TYPE_WITH_PRIVATE (SoupRequestHTTP, soup_request_http, SOUP_TYPE_REQUEST)
@@ -232,3 +233,20 @@ soup_request_http_get_message (SoupRequestHTTP *http)
return g_object_ref (http->priv->msg);
}
+
+void
+soup_request_http_set_block_cookies (SoupRequestHTTP *http,
+ gboolean block_cookies)
+{
+ g_return_if_fail (SOUP_IS_REQUEST_HTTP (http));
+
+ http->priv->block_cookies = block_cookies;
+}
+
+gboolean
+soup_request_http_get_block_cookies (SoupRequestHTTP *http)
+{
+ g_return_val_if_fail (SOUP_IS_REQUEST_HTTP (http), FALSE);
+
+ return http->priv->block_cookies;
+}
\ No newline at end of file
diff --git a/libsoup/soup-request-http.h b/libsoup/soup-request-http.h
index 3a32febd..c7aa5a22 100644
--- a/libsoup/soup-request-http.h
+++ b/libsoup/soup-request-http.h
@@ -51,6 +51,12 @@ GType soup_request_http_get_type (void);
SOUP_AVAILABLE_IN_2_34
SoupMessage *soup_request_http_get_message (SoupRequestHTTP *http);
+SOUP_AVAILABLE_IN_2_66
+void soup_request_http_set_block_cookies (SoupRequestHTTP *http,
+ gboolean block_cookies);
+SOUP_AVAILABLE_IN_2_66
+gboolean soup_request_http_get_block_cookies (SoupRequestHTTP *http);
+
G_END_DECLS
#endif /* __SOUP_REQUEST_HTTP_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]