diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-10-05 23:25:41 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-10-05 23:25:41 +0200 |
commit | f8e92c1eb9d56a41b5461d9a54bbc1b1cb76e812 (patch) | |
tree | 2f6964935b95ea5f2f5932224936d71c0f5af76e /src/microhttpd/response.c | |
parent | 1a23dd25c36bdb0e0be264730e9088a49a1e8152 (diff) | |
download | libmicrohttpd-f8e92c1eb9d56a41b5461d9a54bbc1b1cb76e812.tar.gz libmicrohttpd-f8e92c1eb9d56a41b5461d9a54bbc1b1cb76e812.zip |
use more c99
Diffstat (limited to 'src/microhttpd/response.c')
-rw-r--r-- | src/microhttpd/response.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index fa1cedf4..3a4b7e1b 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c | |||
@@ -169,7 +169,7 @@ MHD_del_response_header (struct MHD_Response *response, | |||
169 | return MHD_NO; | 169 | return MHD_NO; |
170 | prev = NULL; | 170 | prev = NULL; |
171 | pos = response->first_header; | 171 | pos = response->first_header; |
172 | while (pos != NULL) | 172 | while (NULL != pos) |
173 | { | 173 | { |
174 | if ((0 == strcmp (header, | 174 | if ((0 == strcmp (header, |
175 | pos->header)) && | 175 | pos->header)) && |
@@ -207,10 +207,11 @@ MHD_get_response_headers (struct MHD_Response *response, | |||
207 | MHD_KeyValueIterator iterator, | 207 | MHD_KeyValueIterator iterator, |
208 | void *iterator_cls) | 208 | void *iterator_cls) |
209 | { | 209 | { |
210 | struct MHD_HTTP_Header *pos; | ||
211 | int numHeaders = 0; | 210 | int numHeaders = 0; |
212 | 211 | ||
213 | for (pos = response->first_header; NULL != pos; pos = pos->next) | 212 | for (struct MHD_HTTP_Header *pos = response->first_header; |
213 | NULL != pos; | ||
214 | pos = pos->next) | ||
214 | { | 215 | { |
215 | numHeaders++; | 216 | numHeaders++; |
216 | if ((NULL != iterator) && | 217 | if ((NULL != iterator) && |
@@ -236,11 +237,11 @@ const char * | |||
236 | MHD_get_response_header (struct MHD_Response *response, | 237 | MHD_get_response_header (struct MHD_Response *response, |
237 | const char *key) | 238 | const char *key) |
238 | { | 239 | { |
239 | struct MHD_HTTP_Header *pos; | ||
240 | |||
241 | if (NULL == key) | 240 | if (NULL == key) |
242 | return NULL; | 241 | return NULL; |
243 | for (pos = response->first_header; NULL != pos; pos = pos->next) | 242 | for (struct MHD_HTTP_Header *pos = response->first_header; |
243 | NULL != pos; | ||
244 | pos = pos->next) | ||
244 | { | 245 | { |
245 | if ( MHD_str_equal_caseless_ (pos->header, key) ) | 246 | if ( MHD_str_equal_caseless_ (pos->header, key) ) |
246 | return pos->value; | 247 | return pos->value; |
@@ -253,6 +254,7 @@ MHD_get_response_header (struct MHD_Response *response, | |||
253 | * | 254 | * |
254 | * Token could be surrounded by spaces and tabs and delimited by comma. | 255 | * Token could be surrounded by spaces and tabs and delimited by comma. |
255 | * Case-insensitive match used for header names and tokens. | 256 | * Case-insensitive match used for header names and tokens. |
257 | * | ||
256 | * @param response the response to query | 258 | * @param response the response to query |
257 | * @param key header name | 259 | * @param key header name |
258 | * @param token the token to find | 260 | * @param token the token to find |
@@ -267,16 +269,22 @@ MHD_check_response_header_token_ci (const struct MHD_Response *response, | |||
267 | const char *token, | 269 | const char *token, |
268 | size_t token_len) | 270 | size_t token_len) |
269 | { | 271 | { |
270 | struct MHD_HTTP_Header *pos; | 272 | if ( (NULL == key) || |
271 | 273 | ('\0' == key[0]) || | |
272 | if (NULL == key || 0 == key[0] || NULL == token || 0 == token[0]) | 274 | (NULL == token) || |
275 | ('\0' == token[0]) ) | ||
273 | return false; | 276 | return false; |
274 | 277 | ||
275 | for (pos = response->first_header; NULL != pos; pos = pos->next) | 278 | for (struct MHD_HTTP_Header *pos = response->first_header; |
279 | NULL != pos; | ||
280 | pos = pos->next) | ||
276 | { | 281 | { |
277 | if ( (pos->kind == MHD_HEADER_KIND) && | 282 | if ( (pos->kind == MHD_HEADER_KIND) && |
278 | MHD_str_equal_caseless_ (pos->header, key) && | 283 | MHD_str_equal_caseless_ (pos->header, |
279 | MHD_str_has_token_caseless_ (pos->value, token, token_len) ) | 284 | key) && |
285 | MHD_str_has_token_caseless_ (pos->value, | ||
286 | token, | ||
287 | token_len) ) | ||
280 | return true; | 288 | return true; |
281 | } | 289 | } |
282 | return false; | 290 | return false; |