diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-05-08 19:22:34 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-05-09 22:20:42 +0300 |
commit | ad7652a28c4308c24457fb98cc24dbce3c869201 (patch) | |
tree | 7f63a7be3655e1d704ab315fb43e17a67b617056 /src/microhttpd/response.c | |
parent | e93439da71e027cafe5b2788a997cbfc85d193c8 (diff) | |
download | libmicrohttpd-ad7652a28c4308c24457fb98cc24dbce3c869201.tar.gz libmicrohttpd-ad7652a28c4308c24457fb98cc24dbce3c869201.zip |
Added internal function for finding token in response headers MHD_check_response_header_token_ci()
Diffstat (limited to 'src/microhttpd/response.c')
-rw-r--r-- | src/microhttpd/response.c | 34 |
1 files changed, 34 insertions, 0 deletions
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, | |||
248 | return NULL; | 248 | return NULL; |
249 | } | 249 | } |
250 | 250 | ||
251 | /** | ||
252 | * Check whether response header contains particular token. | ||
253 | * | ||
254 | * Token could be surrounded by spaces and tabs and delimited by comma. | ||
255 | * Case-insensitive match used for header names and tokens. | ||
256 | * @param response the response to query | ||
257 | * @param key header name | ||
258 | * @param token the token to find | ||
259 | * @param token_len the length of token, not including optional | ||
260 | * terminating null-character. | ||
261 | * @return true if token is found in specified header, | ||
262 | * false otherwise | ||
263 | */ | ||
264 | bool | ||
265 | MHD_check_response_header_token_ci (const struct MHD_Response *response, | ||
266 | const char *key, | ||
267 | const char *token, | ||
268 | size_t token_len) | ||
269 | { | ||
270 | struct MHD_HTTP_Header *pos; | ||
271 | |||
272 | if (NULL == key || 0 == key[0] || NULL == token || 0 == token[0]) | ||
273 | return false; | ||
274 | |||
275 | for (pos = response->first_header; NULL != pos; pos = pos->next) | ||
276 | { | ||
277 | if ( (pos->kind == MHD_HEADER_KIND) && | ||
278 | MHD_str_equal_caseless_ (pos->header, key) && | ||
279 | MHD_str_has_token_caseless_ (pos->value, token, token_len) ) | ||
280 | return true; | ||
281 | } | ||
282 | return false; | ||
283 | } | ||
284 | |||
251 | 285 | ||
252 | /** | 286 | /** |
253 | * Create a response object. The response object can be extended with | 287 | * Create a response object. The response object can be extended with |