aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-10-22 18:28:09 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-10-28 12:13:07 +0300
commitb44b4f73dd5e3920983f885722a4b7a572b41e10 (patch)
tree5a95c28a9b14bc8b8324ba0dc51d29d2593a26f6
parent9b86ff304c83ffee301130925a233635a0be72a5 (diff)
downloadlibmicrohttpd-b44b4f73dd5e3920983f885722a4b7a572b41e10.tar.gz
libmicrohttpd-b44b4f73dd5e3920983f885722a4b7a572b41e10.zip
test_head: added check for excess data in reply
-rw-r--r--src/testcurl/test_head.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/testcurl/test_head.c b/src/testcurl/test_head.c
index 6ce78217..27daf66e 100644
--- a/src/testcurl/test_head.c
+++ b/src/testcurl/test_head.c
@@ -434,6 +434,54 @@ setCURL_rq_path (CURL *c, int uri_exist)
434} 434}
435 435
436 436
437static int
438libcurl_debug_cb (CURL *handle,
439 curl_infotype type,
440 char *data,
441 size_t size,
442 void *userptr)
443{
444 static const char excess_mark[] = "Excess found";
445 static const size_t excess_mark_len = MHD_STATICSTR_LEN_ (excess_mark);
446
447 (void) handle;
448 (void) userptr;
449
450#ifdef _DEBUG
451 switch (type)
452 {
453 case CURLINFO_TEXT:
454 fprintf (stderr, "* %.*s", (int) size, data);
455 break;
456 case CURLINFO_HEADER_IN:
457 fprintf (stderr, "< %.*s", (int) size, data);
458 break;
459 case CURLINFO_HEADER_OUT:
460 fprintf (stderr, "> %.*s", (int) size, data);
461 break;
462 case CURLINFO_DATA_IN:
463#if 0
464 fprintf (stderr, "<| %.*s\n", (int) size, data);
465#endif
466 break;
467 case CURLINFO_DATA_OUT:
468 case CURLINFO_SSL_DATA_IN:
469 case CURLINFO_SSL_DATA_OUT:
470 case CURLINFO_END:
471 default:
472 break;
473 }
474#endif /* _DEBUG */
475 if (CURLINFO_TEXT == type)
476 {
477 if ((size >= excess_mark_len) &&
478 (0 == memcmp (data, excess_mark, excess_mark_len)))
479 mhdErrorExitDesc ("Extra data has been detected in MHD reply");
480 }
481 return 0;
482}
483
484
437static CURL * 485static CURL *
438setupCURL (void *cbc, uint16_t port, 486setupCURL (void *cbc, uint16_t port,
439 struct headers_check_result *hdr_chk_result) 487 struct headers_check_result *hdr_chk_result)
@@ -466,6 +514,8 @@ setupCURL (void *cbc, uint16_t port,
466#ifdef _DEBUG 514#ifdef _DEBUG
467 (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) || 515 (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) ||
468#endif /* _DEBUG */ 516#endif /* _DEBUG */
517 (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION,
518 &libcurl_debug_cb)) ||
469#if CURL_AT_LEAST_VERSION (7, 19, 4) 519#if CURL_AT_LEAST_VERSION (7, 19, 4)
470 (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) || 520 (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) ||
471#endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ 521#endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */