[libsoup/carlosgc/message-feature-is-disabled: 2/2] soup-message: make soup_message_disables_feature_by_type() public
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/carlosgc/message-feature-is-disabled: 2/2] soup-message: make soup_message_disables_feature_by_type() public
- Date: Mon, 6 Jul 2020 09:45:08 +0000 (UTC)
commit 4ec09b214ad059503ff188e13a27179d484c9857
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Mon Jul 6 11:41:16 2020 +0200
soup-message: make soup_message_disables_feature_by_type() public
Renamed as soup_message_is_feature_disabled(). We need this in WebKit to
check if cookies are available in an existing SoupMessage.
docs/reference/libsoup-2.4-sections.txt | 1 +
libsoup/soup-message-private.h | 2 --
libsoup/soup-message.c | 15 ++++++++++++++-
libsoup/soup-message.h | 4 ++++
libsoup/soup-version.h.in | 8 ++++++++
libsoup/soup-websocket.c | 2 +-
tests/sniffing-test.c | 4 ++++
7 files changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt
index dac47136..26ddfbb2 100644
--- a/docs/reference/libsoup-2.4-sections.txt
+++ b/docs/reference/libsoup-2.4-sections.txt
@@ -35,6 +35,7 @@ SoupChunkAllocator
soup_message_set_chunk_allocator
<SUBSECTION>
soup_message_disable_feature
+soup_message_is_feature_disabled
soup_message_get_soup_request
<SUBSECTION>
SoupMessagePriority
diff --git a/libsoup/soup-message-private.h b/libsoup/soup-message-private.h
index 59762e84..c30361c0 100644
--- a/libsoup/soup-message-private.h
+++ b/libsoup/soup-message-private.h
@@ -143,8 +143,6 @@ GInputStream *soup_message_io_get_response_istream (SoupMessage *msg,
gboolean soup_message_disables_feature (SoupMessage *msg,
gpointer feature);
-gboolean soup_message_disables_feature_by_type (SoupMessage *msg,
- GType feature_type);
GList *soup_message_get_disabled_features (SoupMessage *msg);
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index 1801c619..da32b42f 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -1927,8 +1927,21 @@ soup_message_disables_feature (SoupMessage *msg, gpointer feature)
return FALSE;
}
+/**
+ * soup_message_is_feature_disabled:
+ * @msg: a #SoupMessage
+ * @feature_type: the #GType of a #SoupSessionFeature
+ *
+ * Get whether #SoupSessionFeature<!-- -->s of the given @feature_type
+ * (or a subclass of that type) are disabled on @msg.
+ * See soup_message_disable_feature().
+ *
+ * Returns: %TRUE if feature is disabled, or %FALSE otherwise.
+ *
+ * Since: 2.72
+ */
gboolean
-soup_message_disables_feature_by_type (SoupMessage *msg, GType feature_type)
+soup_message_is_feature_disabled (SoupMessage *msg, GType feature_type)
{
SoupMessagePrivate *priv;
GHashTableIter iter;
diff --git a/libsoup/soup-message.h b/libsoup/soup-message.h
index 41004fd9..42379a4b 100644
--- a/libsoup/soup-message.h
+++ b/libsoup/soup-message.h
@@ -217,6 +217,10 @@ SOUP_AVAILABLE_IN_2_28
void soup_message_disable_feature (SoupMessage *msg,
GType feature_type);
+SOUP_AVAILABLE_IN_2_72
+gboolean soup_message_is_feature_disabled (SoupMessage *msg,
+ GType feature_type);
+
SOUP_AVAILABLE_IN_2_42
SoupRequest *soup_message_get_soup_request (SoupMessage *msg);
diff --git a/libsoup/soup-version.h.in b/libsoup/soup-version.h.in
index b06b5ad0..07bed7fd 100644
--- a/libsoup/soup-version.h.in
+++ b/libsoup/soup-version.h.in
@@ -69,6 +69,7 @@ G_BEGIN_DECLS
#define SOUP_VERSION_2_66 (G_ENCODE_VERSION (2, 66))
#define SOUP_VERSION_2_68 (G_ENCODE_VERSION (2, 68))
#define SOUP_VERSION_2_70 (G_ENCODE_VERSION (2, 70))
+#define SOUP_VERSION_2_72 (G_ENCODE_VERSION (2, 72))
/* evaluates to the current stable version; for development cycles,
* this means the next stable target
@@ -410,6 +411,13 @@ G_BEGIN_DECLS
#else
# define SOUP_AVAILABLE_IN_2_70 _SOUP_EXTERN
#endif
+
+#if SOUP_VERSION_MAX_ALLOWED < SOUP_VERSION_2_72
+# define SOUP_AVAILABLE_IN_2_72 G_UNAVAILABLE(2, 72) _SOUP_EXTERN
+#else
+# define SOUP_AVAILABLE_IN_2_72 _SOUP_EXTERN
+#endif
+
SOUP_AVAILABLE_IN_2_42
guint soup_get_major_version (void);
diff --git a/libsoup/soup-websocket.c b/libsoup/soup-websocket.c
index d7011b49..13b56474 100644
--- a/libsoup/soup-websocket.c
+++ b/libsoup/soup-websocket.c
@@ -337,7 +337,7 @@ soup_websocket_client_prepare_handshake_with_extensions (SoupMessage *msg,
for (i = 0; i < supported_extensions->len; i++) {
SoupWebsocketExtensionClass *extension_class = (SoupWebsocketExtensionClass
*)supported_extensions->pdata[i];
- if (soup_message_disables_feature_by_type (msg, G_TYPE_FROM_CLASS (extension_class)))
+ if (soup_message_is_feature_disabled (msg, G_TYPE_FROM_CLASS (extension_class)))
continue;
if (i != 0)
diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c
index 7b391178..d2aa86b9 100644
--- a/tests/sniffing-test.c
+++ b/tests/sniffing-test.c
@@ -403,7 +403,9 @@ test_disabled (gconstpointer data)
uri = soup_uri_new_with_base (base_uri, path);
msg = soup_message_new_from_uri ("GET", uri);
+ g_assert_false (soup_message_is_feature_disabled (msg, SOUP_TYPE_CONTENT_SNIFFER));
soup_message_disable_feature (msg, SOUP_TYPE_CONTENT_SNIFFER);
+ g_assert_true (soup_message_is_feature_disabled (msg, SOUP_TYPE_CONTENT_SNIFFER));
g_signal_connect (msg, "content-sniffed",
G_CALLBACK (sniffing_content_sniffed), &sniffed_type);
@@ -415,7 +417,9 @@ test_disabled (gconstpointer data)
req = soup_session_request_uri (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
+ g_assert_false (soup_message_is_feature_disabled (msg, SOUP_TYPE_CONTENT_SNIFFER));
soup_message_disable_feature (msg, SOUP_TYPE_CONTENT_SNIFFER);
+ g_assert_true (soup_message_is_feature_disabled (msg, SOUP_TYPE_CONTENT_SNIFFER));
g_object_unref (msg);
stream = soup_test_request_send (req, NULL, 0, &error);
if (stream) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]