diff options
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 |