[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
- [GNUnet-SVN] [libmicrohttpd] branch master updated (4809ee65 -> e0825eab), gnunet, 2017/05/09
- [GNUnet-SVN] [libmicrohttpd] 01/06: Fixed missing include, gnunet, 2017/05/09
- [GNUnet-SVN] [libmicrohttpd] 03/06: Added internal function for finding token in response headers MHD_check_response_header_token_ci(),
gnunet <=
- [GNUnet-SVN] [libmicrohttpd] 05/06: Added internal function for finding token in request headers, gnunet, 2017/05/09
- [GNUnet-SVN] [libmicrohttpd] 02/06: Added function for detection of token inside comma-separated string, added tests, gnunet, 2017/05/09
- [GNUnet-SVN] [libmicrohttpd] 04/06: Detect several tokens in single header line of response., gnunet, 2017/05/09
- [GNUnet-SVN] [libmicrohttpd] 06/06: Fixed: check all request "Connection" headers for "Close" and "Upgrade" tokens instead of using only first "Connection" header with full string match., gnunet, 2017/05/09