libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 5c478c5d61b06ebd581d18c28e3906b1e7e2101b
parent cca1730f8b1ad5b89c1d00d37da37edb173c02e5
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 28 Nov 2021 13:21:53 +0300

test_client_put_stop: check for right reason

The termination reason must correspond to type of client socket closure.

Diffstat:
Msrc/microhttpd/test_client_put_stop.c | 21++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/microhttpd/test_client_put_stop.c b/src/microhttpd/test_client_put_stop.c @@ -1384,8 +1384,11 @@ performTestQueries (struct MHD_Daemon *d, int d_port, int ret = 0; /* Return value */ size_t req_total_size; size_t limit_send_size; + int expected_reason; + int found_right_reason; - /* Common parameters, to be individually overridden by specific test cases */ + /* Common parameters, to be individually overridden by specific test cases + * if needed */ qParam.queryPort = d_port; qParam.method = MHD_HTTP_METHOD_PUT; qParam.queryPath = EXPECTED_URI_BASE_PATH; @@ -1415,6 +1418,10 @@ performTestQueries (struct MHD_Daemon *d, int d_port, _MHD_dumbClient_close (test_c); } while (0); + expected_reason = use_hard_close ? + MHD_REQUEST_TERMINATED_READ_ERROR : + MHD_REQUEST_TERMINATED_CLIENT_ABORT; + found_right_reason = 0; for (limit_send_size = 1; limit_send_size < req_total_size; limit_send_size++) { int test_succeed; @@ -1452,7 +1459,11 @@ performTestQueries (struct MHD_Daemon *d, int d_port, else if (1 != sckt_result->num_finished) fprintf (stderr, "FAILED: Wrong number of sockets closed."); else + { test_succeed = 1; + if (expected_reason == term_result->term_reason) + found_right_reason = 1; + } } if (! test_succeed) @@ -1477,6 +1488,14 @@ performTestQueries (struct MHD_Daemon *d, int d_port, free (term_result); free (sckt_result); + if (! found_right_reason) + { + fprintf (stderr, "FAILED: termination callback was not called with " + "expected (%s) reason.\n", term_reason_str (expected_reason)); + fflush (stderr); + ret |= 1 << 1; + } + return ret; }