[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 05/06: Added internal function for finding
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 05/06: Added internal function for finding token in request headers |
Date: |
Tue, 09 May 2017 21:34:11 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 17d1176f26fb679602b990e8194bf21a1c92d005
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Tue May 9 21:37:44 2017 +0300
Added internal function for finding token in request headers
---
src/microhttpd/connection.c | 51 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 8c91f468..6c7d5226 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -468,6 +468,57 @@ MHD_lookup_connection_value (struct MHD_Connection
*connection,
/**
+ * Check whether request 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 connection the connection to get values from
+ * @param header the 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
+ */
+static bool
+MHD_lookup_header_token_ci (const struct MHD_Connection *connection,
+ const char *header,
+ const char *token,
+ size_t token_len)
+{
+ struct MHD_HTTP_Header *pos;
+
+ if (NULL == connection || NULL == header || 0 == header[0] || NULL == token
|| 0 == token[0])
+ return false;
+ for (pos = connection->headers_received; NULL != pos; pos = pos->next)
+ {
+ if ((0 != (pos->kind & MHD_HEADER_KIND)) &&
+ ( (header == pos->header) ||
+ (MHD_str_equal_caseless_(header,
+ pos->header)) ) &&
+ (MHD_str_has_token_caseless_ (pos->value, token, token_len)))
+ return true;
+ }
+ return false;
+}
+
+
+/**
+ * Check whether request 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 c the connection to get values from
+ * @param h the header name
+ * @param tkn the static string of token to find
+ * @return true if token is found in specified header,
+ * false otherwise
+ */
+#define MHD_lookup_header_s_token_ci(c,h,tkn) \
+ MHD_lookup_header_token_ci((c),(h),(tkn),MHD_STATICSTR_LEN_(tkn))
+
+
+/**
* Do we (still) need to send a 100 continue
* message for this connection?
*
--
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, 2017/05/09
- [GNUnet-SVN] [libmicrohttpd] 05/06: Added internal function for finding token in request headers,
gnunet <=
- [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