[PATCH v2 03/22] gweb: Added 'g_web_result_has_headers'.

Grant Erickson <[email protected]>
Newsgroups dev.linux.lists.connman
Message-ID <33b4c08a164f2a8030dd86e254d79f25ac7762de.1741059516.git.gerickson@nuovations.com>
Return whether the web session request result has any HTTP headers
and, if requested, the header count.
---
 gweb/gweb.c | 16 ++++++++++++++++
 gweb/gweb.h |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/gweb/gweb.c b/gweb/gweb.c
index d4bdbdd641f5..76f01c44b88f 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -2504,6 +2504,22 @@ bool g_web_result_get_header(GWebResult *result,
 	return true;
 }
 
+bool g_web_result_has_headers(const GWebResult *result,
+				guint *count)
+{
+	guint size;
+
+	if (!result)
+		return false;
+
+	size = g_hash_table_size(result->headers);
+
+	if (count)
+		*count = size;
+
+	return size > 0;
+}
+
 struct _GWebParser {
 	gint ref_count;
 	char *begin_token;
diff --git a/gweb/gweb.h b/gweb/gweb.h
index 7c65aebf4698..90cccadbe883 100644
--- a/gweb/gweb.h
+++ b/gweb/gweb.h
@@ -166,6 +166,8 @@ guint16 g_web_result_get_status(GWebResult *result);
 
 bool g_web_result_get_header(GWebResult *result,
 				const char *header, const char **value);
+bool g_web_result_has_headers(const GWebResult *result,
+				guint *count);
 bool g_web_result_get_chunk(GWebResult *result,
 				const guint8 **chunk, gsize *length);
 
-- 
2.45.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.