libmicrohttpd

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

commit 4595a443ed295d5d987908576acd145d18d360c6
parent 564c9533068ac97fe6042b539e718e51fa58dbf7
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 15 Aug 2021 18:23:33 +0300

Added more chunked response tests

Diffstat:
Msrc/testcurl/.gitignore | 2++
Msrc/testcurl/Makefile.am | 14++++++++++++++
Msrc/testcurl/test_get_chunked.c | 16+++++++++++++---
3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/testcurl/.gitignore b/src/testcurl/.gitignore @@ -37,6 +37,8 @@ /test_get_chunked_close_sized /test_get_chunked_empty_sized /test_get_chunked_close_empty_sized +/test_get_chunked_forced +/test_get_chunked_empty_forced /test_get11 /test_get /test_digestauth_with_arguments diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am @@ -110,6 +110,8 @@ check_PROGRAMS = \ test_get_chunked_close_sized \ test_get_chunked_empty_sized \ test_get_chunked_close_empty_sized \ + test_get_chunked_forced \ + test_get_chunked_empty_forced \ test_put_chunked \ test_callback \ $(EMPTY_ITEM) @@ -346,6 +348,18 @@ test_get_chunked_close_empty_sized_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ @LIBCURL@ +test_get_chunked_forced_SOURCES = \ + test_get_chunked.c +test_get_chunked_forced_LDADD = \ + $(top_builddir)/src/microhttpd/libmicrohttpd.la \ + @LIBCURL@ + +test_get_chunked_empty_forced_SOURCES = \ + test_get_chunked.c +test_get_chunked_empty_forced_LDADD = \ + $(top_builddir)/src/microhttpd/libmicrohttpd.la \ + @LIBCURL@ + test_post_SOURCES = \ test_post.c mhd_has_in_name.h test_post_LDADD = \ diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c @@ -76,6 +76,11 @@ int resp_sized; */ int resp_empty; +/** + * Force chunked response by response header? + */ +int chunked_forced; + struct headers_check_result { @@ -225,14 +230,14 @@ ahc_echo (void *cls, } if (NULL == response) abort (); - if (conn_close || resp_sized) - { /* Enforce chunked response even for non-Keep-Alive and static responses */ + if (chunked_forced) + { if (MHD_NO == MHD_add_response_header (response, MHD_HTTP_HEADER_TRANSFER_ENCODING, "chunked")) abort (); } - if (resp_string) + if (resp_string || (resp_sized && resp_empty)) { /* There is no chance to add footer later */ if (MHD_YES != MHD_add_response_footer (response, @@ -737,8 +742,13 @@ main (int argc, char *const *argv) resp_string = has_in_name (argv[0], "_string"); resp_sized = has_in_name (argv[0], "_sized"); resp_empty = has_in_name (argv[0], "_empty"); + chunked_forced = has_in_name (argv[0], "_forced"); if (resp_string) resp_sized = ! 0; + if (resp_sized) + chunked_forced = ! 0; + if (conn_close) /* TODO: remove when supported by MHD */ + chunked_forced = ! 0; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalGet ();