gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (26288b11 -> 0560bb09)


From: gnunet
Subject: [libmicrohttpd] branch master updated (26288b11 -> 0560bb09)
Date: Sun, 20 Jun 2021 15:33:20 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 26288b11 Response: fixed order of the headers
     new 91a0d62e internal.h: reordered items
     new 32a9f1dc response: added MHD_get_response_element_n() function
     new 0560bb09 MHD_add_response_header(): improved doxy

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/include/microhttpd.h  |  4 +++-
 src/microhttpd/internal.h | 30 +++++++++++++++---------------
 src/microhttpd/response.c | 40 +++++++++++++++++++++++++++++++++++++++-
 src/microhttpd/response.h | 19 +++++++++++++++++++
 4 files changed, 76 insertions(+), 17 deletions(-)

diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 4f09bee5..b9ea600d 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -3614,7 +3614,7 @@ MHD_destroy_response (struct MHD_Response *response);
  *
  * When reply is generated with queued response, some headers are generated
  * automatically. Automatically generated headers are only sent to the client,
- * but not added back to the response.
+ * but not added back to the response object.
  *
  * The list of automatic headers:
  * + "Date" header is added automatically unless already set by
@@ -3633,6 +3633,8 @@ MHD_destroy_response (struct MHD_Response *response);
  *   to enforce closure of the connection after sending this response.
  *   "Keep-Alive" cannot be enforced and will be removed automatically.
  *
+ * Headers are used in order as they were added.
+ *
  * @param response the response to add a header to
  * @param header the header name to add
  * @param content the header value to add
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 460cbf1b..2338c0ee 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -778,6 +778,21 @@ enum MHD_HTTP_Version
   MHD_HTTP_VER_FUTURE = 100
 };
 
+/**
+ * Returns boolean 'true' if HTTP version is supported by MHD
+ */
+#define MHD_IS_HTTP_VER_SUPPORTED(ver) (MHD_HTTP_VER_1_0 <= (ver) && \
+    MHD_HTTP_VER_1_2__1_9 >= (ver))
+
+/**
+ * Protocol should be used as HTTP/1.1 protocol.
+ *
+ * See the last paragraph of
+ * https://datatracker.ietf.org/doc/html/rfc7230#section-2.6
+ */
+#define MHD_IS_HTTP_VER_1_1_COMPAT(ver) (MHD_HTTP_VER_1_1 == (ver) || \
+    MHD_HTTP_VER_1_2__1_9 == (ver))
+
 /**
  * The HTTP method.
  *
@@ -827,21 +842,6 @@ enum MHD_HTTP_Method
   MHD_HTTP_MTHD_OTHER = 1000
 };
 
-/**
- * Returns boolean 'true' if HTTP version is supported by MHD
- */
-#define MHD_IS_HTTP_VER_SUPPORTED(ver) (MHD_HTTP_VER_1_0 <= (ver) && \
-    MHD_HTTP_VER_1_2__1_9 >= (ver))
-
-/**
- * Protocol should be used as HTTP/1.1 protocol.
- *
- * See the last paragraph of
- * https://datatracker.ietf.org/doc/html/rfc7230#section-2.6
- */
-#define MHD_IS_HTTP_VER_1_1_COMPAT(ver) (MHD_HTTP_VER_1_1 == (ver) || \
-    MHD_HTTP_VER_1_2__1_9 == (ver))
-
 /**
  * State kept for each HTTP request.
  */
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 7e3deaf8..c91125eb 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -198,7 +198,7 @@ add_response_entry (struct MHD_Response *response,
  *
  * When reply is generated with queued response, some headers are generated
  * automatically. Automatically generated headers are only sent to the client,
- * but not added back to the response.
+ * but not added back to the response object.
  *
  * The list of automatic headers:
  * + "Date" header is added automatically unless already set by
@@ -217,6 +217,8 @@ add_response_entry (struct MHD_Response *response,
  *   to enforce closure of the connection after sending this response.
  *   "Keep-Alive" cannot be enforced and will be removed automatically.
  *
+ * Headers are used in order as they were added.
+ *
  * @param response the response to add a header to
  * @param header the header name to add
  * @param content the header value to add
@@ -399,6 +401,42 @@ MHD_get_response_header (struct MHD_Response *response,
 }
 
 
+/**
+ * Get a particular header (or footer) element from the response.
+ *
+ * Function returns the first found element.
+ * @param response response to query
+ * @param kind the kind of element: header or footer
+ * @param key the key which header to get
+ * @param key_len the length of the @a key
+ * @return NULL if header elemnt does not exist
+ * @ingroup response
+ */
+struct MHD_HTTP_Header *
+MHD_get_response_element_n_ (struct MHD_Response *response,
+                             enum MHD_ValueKind kind,
+                             const char *key,
+                             size_t key_len)
+{
+  struct MHD_HTTP_Header *pos;
+
+  mhd_assert (NULL != key);
+  mhd_assert (0 != key[0]);
+  mhd_assert (0 != key_len);
+
+  for (pos = response->first_header;
+       NULL != pos;
+       pos = pos->next)
+  {
+    if ((pos->header_size == key_len) &&
+        (kind == pos->kind) &&
+        (MHD_str_equal_caseless_bin_n_ (pos->header, key, pos->header_size)))
+      return pos;
+  }
+  return NULL;
+}
+
+
 /**
  * Check whether response header contains particular token.
  *
diff --git a/src/microhttpd/response.h b/src/microhttpd/response.h
index 03448e56..52dece93 100644
--- a/src/microhttpd/response.h
+++ b/src/microhttpd/response.h
@@ -1,6 +1,7 @@
 /*
      This file is part of libmicrohttpd
      Copyright (C) 2007 Daniel Pittman and Christian Grothoff
+     Copyright (C) 2015-2021 Karlson2k (Evgeny Grin)
 
      This library is free software; you can redistribute it and/or
      modify it under the terms of the GNU Lesser General Public
@@ -22,6 +23,7 @@
  * @brief  Methods for managing response objects
  * @author Daniel Pittman
  * @author Christian Grothoff
+ * @author Karlson2k (Evgeny Grin)
  */
 
 #ifndef RESPONSE_H
@@ -54,4 +56,21 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
                                struct MHD_Connection *connection);
 
 
+/**
+ * Get a particular header (or footer) element from the response.
+ *
+ * Function returns the first found element.
+ * @param response response to query
+ * @param kind the kind of element: header or footer
+ * @param key the key which header to get
+ * @param key_len the length of the @a key
+ * @return NULL if header elemnt does not exist
+ * @ingroup response
+ */
+struct MHD_HTTP_Header *
+MHD_get_response_element_n_ (struct MHD_Response *response,
+                             enum MHD_ValueKind kind,
+                             const char *key,
+                             size_t key_len);
+
 #endif

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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