[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 02/03: response: added MHD_get_response_element_n() func
From: |
gnunet |
Subject: |
[libmicrohttpd] 02/03: response: added MHD_get_response_element_n() function |
Date: |
Sun, 20 Jun 2021 15:33:22 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 32a9f1dc4df378defaf1d5e7252b9241921f2191
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Tue Jun 8 13:56:38 2021 +0300
response: added MHD_get_response_element_n() function
---
src/microhttpd/response.c | 36 ++++++++++++++++++++++++++++++++++++
src/microhttpd/response.h | 19 +++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 7e3deaf8..e1f2aebf 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -399,6 +399,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.