gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] 03/06: Added internal function for finding


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 03/06: Added internal function for finding token in response headers MHD_check_response_header_token_ci()
Date: Tue, 09 May 2017 21:34:09 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit ad7652a28c4308c24457fb98cc24dbce3c869201
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Mon May 8 19:22:34 2017 +0300

    Added internal function for finding token in response headers 
MHD_check_response_header_token_ci()
---
 src/microhttpd/internal.h | 34 ++++++++++++++++++++++++++++++++++
 src/microhttpd/response.c | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+)

diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index a9c46c6d..e2d8cfb6 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -1888,4 +1888,38 @@ MHD_parse_arguments_ (struct MHD_Connection *connection,
                      unsigned int *num_headers);
 
 
+/**
+ * Check whether response header contains particular @a token.
+ *
+ * Token could be surrounded by spaces and tabs and delimited by comma.
+ * Case-insensitive match used for header names and tokens.
+ * @param response  the response to query
+ * @param key       header name
+ * @param token     the token to find
+ * @param token_len the length of token, not including optional
+ *                  terminating null-character.
+ * @return true if token is found in specified header,
+ *         false otherwise
+ */
+bool
+MHD_check_response_header_token_ci (const struct MHD_Response *response,
+                                    const char *key,
+                                    const char *token,
+                                    size_t token_len);
+
+/**
+ * Check whether response header contains particular static @a tkn.
+ *
+ * Token could be surrounded by spaces and tabs and delimited by comma.
+ * Case-insensitive match used for header names and tokens.
+ * @param r   the response to query
+ * @param k   header name
+ * @param tkn the static string of token to find
+ * @return true if token is found in specified header,
+ *         false otherwise
+ */
+#define MHD_check_response_header_s_token_ci(r,k,tkn) \
+    MHD_check_response_header_token_ci((r),(k),(tkn),MHD_STATICSTR_LEN_(tkn))
+
+
 #endif
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index de79ed1a..5ab97b35 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -248,6 +248,40 @@ MHD_get_response_header (struct MHD_Response *response,
   return NULL;
 }
 
+/**
+ * Check whether response header contains particular token.
+ *
+ * Token could be surrounded by spaces and tabs and delimited by comma.
+ * Case-insensitive match used for header names and tokens.
+ * @param response  the response to query
+ * @param key       header name
+ * @param token     the token to find
+ * @param token_len the length of token, not including optional
+ *                  terminating null-character.
+ * @return true if token is found in specified header,
+ *         false otherwise
+ */
+bool
+MHD_check_response_header_token_ci (const struct MHD_Response *response,
+                                    const char *key,
+                                    const char *token,
+                                    size_t token_len)
+{
+  struct MHD_HTTP_Header *pos;
+
+  if (NULL == key || 0 == key[0] || NULL == token || 0 == token[0])
+    return false;
+
+  for (pos = response->first_header; NULL != pos; pos = pos->next)
+    {
+      if ( (pos->kind == MHD_HEADER_KIND) &&
+           MHD_str_equal_caseless_ (pos->header, key) &&
+           MHD_str_has_token_caseless_ (pos->value, token, token_len) )
+        return true;
+    }
+  return false;
+}
+
 
 /**
  * Create a response object.  The response object can be extended with

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



reply via email to

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