[libsoup/websocket: 6/10] soup-message-headers: add new APIs
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/websocket: 6/10] soup-message-headers: add new APIs
- Date: Sun, 14 Dec 2014 14:30:00 +0000 (UTC)
commit 01742a3b179949989589ee5a13c2d850094ffbb5
Author: Lionel Landwerlin <llandwerlin gmail com>
Date: Sun Nov 30 10:10:20 2014 -0500
soup-message-headers: add new APIs
Add soup_message_headers_get_header_type(),
soup_message_headers_header_contains(), and
soup_message_headers_header_equals().
docs/reference/libsoup-2.4-sections.txt | 4 ++
libsoup/libsoup-2.4.sym | 3 +
libsoup/soup-message-headers.c | 69 +++++++++++++++++++++++++++++++
libsoup/soup-message-headers.h | 11 +++++
4 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt
index ba8b2b4..433fa89 100644
--- a/docs/reference/libsoup-2.4-sections.txt
+++ b/docs/reference/libsoup-2.4-sections.txt
@@ -118,6 +118,10 @@ soup_message_headers_clean_connection_headers
soup_message_headers_get_one
soup_message_headers_get_list
soup_message_headers_get
+soup_message_headers_get_headers_type
+<SUBSECTION>
+soup_message_headers_header_contains
+soup_message_headers_header_equals
<SUBSECTION>
SoupMessageHeadersForeachFunc
soup_message_headers_foreach
diff --git a/libsoup/libsoup-2.4.sym b/libsoup/libsoup-2.4.sym
index 39f26d1..642cd0c 100644
--- a/libsoup/libsoup-2.4.sym
+++ b/libsoup/libsoup-2.4.sym
@@ -277,10 +277,13 @@ soup_message_headers_get_content_range
soup_message_headers_get_content_type
soup_message_headers_get_encoding
soup_message_headers_get_expectations
+soup_message_headers_get_headers_type
soup_message_headers_get_list
soup_message_headers_get_one
soup_message_headers_get_ranges
soup_message_headers_get_type
+soup_message_headers_header_contains
+soup_message_headers_header_equals
soup_message_headers_iter_init
soup_message_headers_iter_next
soup_message_headers_new
diff --git a/libsoup/soup-message-headers.c b/libsoup/soup-message-headers.c
index f4a69d4..6284af1 100644
--- a/libsoup/soup-message-headers.c
+++ b/libsoup/soup-message-headers.c
@@ -110,6 +110,22 @@ soup_message_headers_free (SoupMessageHeaders *hdrs)
G_DEFINE_BOXED_TYPE (SoupMessageHeaders, soup_message_headers, soup_message_headers_copy,
soup_message_headers_free)
/**
+ * soup_message_headers_get_headers_type:
+ * @hdrs: a #SoupMessageHeaders
+ *
+ * Gets the type of headers.
+ *
+ * Return value: the header's type.
+ *
+ * Since: 2.48
+ **/
+SoupMessageHeadersType
+soup_message_headers_get_headers_type (SoupMessageHeaders *hdrs)
+{
+ return hdrs->type;
+}
+
+/**
* soup_message_headers_clear:
* @hdrs: a #SoupMessageHeaders
*
@@ -320,6 +336,59 @@ soup_message_headers_get_one (SoupMessageHeaders *hdrs, const char *name)
}
/**
+ * soup_message_headers_header_contains:
+ * @hdrs: a #SoupMessageHeaders
+ * @name: header name
+ * @token: token to look for
+ *
+ * Checks whether the list-valued header @name is present in @hdrs,
+ * and contains a case-insensitive match for @token.
+ *
+ * (If @name is present in @hdrs, then this is equivalent to calling
+ * soup_header_contains() on its value.)
+ *
+ * Return value: %TRUE if the header is present and contains @token,
+ * %FALSE otherwise.
+ *
+ * Since: 2.48
+ **/
+gboolean
+soup_message_headers_header_contains (SoupMessageHeaders *hdrs, const char *name, const char *token)
+{
+ const char *value;
+
+ value = soup_message_headers_get_list (hdrs, name);
+ if (!value)
+ return FALSE;
+ return soup_header_contains (value, token);
+}
+
+/**
+ * soup_message_headers_header_equals:
+ * @hdrs: a #SoupMessageHeaders
+ * @name: header name
+ * @value: expected value
+ *
+ * Checks whether the header @name is present in @hdrs and is
+ * (case-insensitively) equal to @value.
+ *
+ * Return value: %TRUE if the header is present and its value is
+ * @value, %FALSE otherwise.
+ *
+ * Since: 2.48
+ **/
+gboolean
+soup_message_headers_header_equals (SoupMessageHeaders *hdrs, const char *name, const char *value)
+{
+ const char *internal_value;
+
+ internal_value = soup_message_headers_get_list (hdrs, name);
+ if (!internal_value)
+ return FALSE;
+ return !g_ascii_strcasecmp (internal_value, value);
+}
+
+/**
* soup_message_headers_get_list:
* @hdrs: a #SoupMessageHeaders
* @name: header name
diff --git a/libsoup/soup-message-headers.h b/libsoup/soup-message-headers.h
index 02e752b..2dd22b9 100644
--- a/libsoup/soup-message-headers.h
+++ b/libsoup/soup-message-headers.h
@@ -49,6 +49,14 @@ const char *soup_message_headers_get_one (SoupMessageHeaders *hdrs,
SOUP_AVAILABLE_IN_2_28
const char *soup_message_headers_get_list (SoupMessageHeaders *hdrs,
const char *name);
+SOUP_AVAILABLE_IN_2_48
+gboolean soup_message_headers_header_contains (SoupMessageHeaders *hdrs,
+ const char *name,
+ const char *token);
+SOUP_AVAILABLE_IN_2_48
+gboolean soup_message_headers_header_equals (SoupMessageHeaders *hdrs,
+ const char *name,
+ const char *value);
typedef void (*SoupMessageHeadersForeachFunc)(const char *name,
const char *value,
@@ -58,6 +66,9 @@ void soup_message_headers_foreach (SoupMessageHeaders *hdrs,
SoupMessageHeadersForeachFunc func,
gpointer user_data);
+SOUP_AVAILABLE_IN_2_48
+SoupMessageHeadersType soup_message_headers_get_headers_type (SoupMessageHeaders *hdrs);
+
typedef struct {
/*< private >*/
gpointer dummy[3];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]