gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] 02/02: Added MHD_get_connection_values_n()


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 02/02: Added MHD_get_connection_values_n() function to get keys and values with size. Can get keys and values with binary zero.
Date: Fri, 03 May 2019 18:08:47 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 650d4685f7e9f8297df706d0c220fbd12e6e84d4
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Fri May 3 19:06:19 2019 +0300

    Added MHD_get_connection_values_n() function to get keys and
    values with size. Can get keys and values with binary zero.
---
 src/include/microhttpd.h    | 22 ++++++++++++++++++++-
 src/microhttpd/connection.c | 47 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 3dbda318..a492071a 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -2493,7 +2493,8 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
  * @param iterator callback to call on each header;
  *        maybe NULL (then just count headers)
  * @param iterator_cls extra argument to @a iterator
- * @return number of entries iterated over
+ * @return number of entries iterated over,
+ *         -1 if connection is NULL.
  * @ingroup request
  */
 _MHD_EXTERN int
@@ -2503,6 +2504,25 @@ MHD_get_connection_values (struct MHD_Connection 
*connection,
                            void *iterator_cls);
 
 
+/**
+ * Get all of the headers from the request.
+ *
+ * @param connection connection to get values from
+ * @param kind types of values to iterate over, can be a bitmask
+ * @param iterator callback to call on each header;
+ *        maybe NULL (then just count headers)
+ * @param iterator_cls extra argument to @a iterator
+ * @return number of entries iterated over,
+ *         -1 if connection is NULL.
+ * @ingroup request
+ */
+_MHD_EXTERN int
+MHD_get_connection_values_n (struct MHD_Connection *connection,
+                             enum MHD_ValueKind kind,
+                             MHD_KeyValueIteratorN iterator,
+                             void *iterator_cls);
+
+
 /**
  * This function can be used to add an entry to the HTTP headers of a
  * connection (so that the #MHD_get_connection_values function will
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index d77b023a..9e136b9d 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -684,6 +684,7 @@ socket_start_normal_buffering (struct MHD_Connection 
*connection)
  *        maybe NULL (then just count headers)
  * @param iterator_cls extra argument to @a iterator
  * @return number of entries iterated over
+ *         -1 if connection is NULL.
  * @ingroup request
  */
 int
@@ -713,6 +714,52 @@ MHD_get_connection_values (struct MHD_Connection 
*connection,
 }
 
 
+/**
+ * Get all of the headers from the request.
+ *
+ * @param connection connection to get values from
+ * @param kind types of values to iterate over, can be a bitmask
+ * @param iterator callback to call on each header;
+ *        maybe NULL (then just count headers)
+ * @param iterator_cls extra argument to @a iterator
+ * @return number of entries iterated over,
+ *         -1 if connection is NULL.
+ * @ingroup request
+ */
+int
+MHD_get_connection_values_n (struct MHD_Connection *connection,
+                             enum MHD_ValueKind kind,
+                             MHD_KeyValueIteratorN iterator,
+                             void *iterator_cls)
+{
+  int ret;
+  struct MHD_HTTP_Header *pos;
+
+  if (NULL == connection)
+    return -1;
+  ret = 0;
+
+  if (NULL == iterator)
+    for (pos = connection->headers_received; NULL != pos; pos = pos->next)
+      if (kind == pos->kind)
+        ret++;
+  else
+    for (pos = connection->headers_received; NULL != pos; pos = pos->next)
+      if (kind == pos->kind)
+        {
+          ret++;
+          if (MHD_NO == iterator (iterator_cls,
+                                  pos->kind,
+                                  pos->header,
+                                  pos->header_size,
+                                  pos->value,
+                                  pos->value_size))
+            return ret;
+        }
+  return ret;
+}
+
+
 /**
  * This function can be used to add an arbitrary entry to connection.
  * Internal version of #MHD_set_connection_value_n() without checking

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]