[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] branch master updated: Added more tests for chunked repl
From: |
gnunet |
Subject: |
[libmicrohttpd] branch master updated: Added more tests for chunked reply encoding |
Date: |
Wed, 28 Jul 2021 14:02:38 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
The following commit(s) were added to refs/heads/master by this push:
new 922bf0e5 Added more tests for chunked reply encoding
922bf0e5 is described below
commit 922bf0e5c467cf0ddc7bb30d9de9f495f7b1229d
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed Jul 28 14:59:09 2021 +0300
Added more tests for chunked reply encoding
---
src/testcurl/.gitignore | 6 ++++
src/testcurl/Makefile.am | 42 ++++++++++++++++++++++
src/testcurl/test_get_chunked.c | 79 +++++++++++++++++++++++++++++++++++------
3 files changed, 116 insertions(+), 11 deletions(-)
diff --git a/src/testcurl/.gitignore b/src/testcurl/.gitignore
index ef28dad4..afc792e3 100644
--- a/src/testcurl/.gitignore
+++ b/src/testcurl/.gitignore
@@ -27,6 +27,12 @@
/test_get_response_cleanup
/test_get_chunked
/test_get_chunked_close
+/test_get_chunked_string
+/test_get_chunked_close_string
+/test_get_chunked_empty
+/test_get_chunked_close_empty
+/test_get_chunked_string_empty
+/test_get_chunked_close_string_empty
/test_get11
/test_get
/test_digestauth_with_arguments
diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am
index b21e3ff3..a3180f31 100644
--- a/src/testcurl/Makefile.am
+++ b/src/testcurl/Makefile.am
@@ -100,6 +100,12 @@ check_PROGRAMS = \
test_large_put_inc11 \
test_get_chunked \
test_get_chunked_close \
+ test_get_chunked_string \
+ test_get_chunked_close_string \
+ test_get_chunked_empty \
+ test_get_chunked_close_empty \
+ test_get_chunked_string_empty \
+ test_get_chunked_close_string_empty \
test_put_chunked \
test_callback \
$(EMPTY_ITEM)
@@ -276,6 +282,42 @@ test_get_chunked_close_LDADD = \
$(top_builddir)/src/microhttpd/libmicrohttpd.la \
@LIBCURL@
+test_get_chunked_string_SOURCES = \
+ test_get_chunked.c
+test_get_chunked_string_LDADD = \
+ $(top_builddir)/src/microhttpd/libmicrohttpd.la \
+ @LIBCURL@
+
+test_get_chunked_close_string_SOURCES = \
+ test_get_chunked.c
+test_get_chunked_close_string_LDADD = \
+ $(top_builddir)/src/microhttpd/libmicrohttpd.la \
+ @LIBCURL@
+
+test_get_chunked_empty_SOURCES = \
+ test_get_chunked.c
+test_get_chunked_empty_LDADD = \
+ $(top_builddir)/src/microhttpd/libmicrohttpd.la \
+ @LIBCURL@
+
+test_get_chunked_close_empty_SOURCES = \
+ test_get_chunked.c
+test_get_chunked_close_empty_LDADD = \
+ $(top_builddir)/src/microhttpd/libmicrohttpd.la \
+ @LIBCURL@
+
+test_get_chunked_string_empty_SOURCES = \
+ test_get_chunked.c
+test_get_chunked_string_empty_LDADD = \
+ $(top_builddir)/src/microhttpd/libmicrohttpd.la \
+ @LIBCURL@
+
+test_get_chunked_close_string_empty_SOURCES = \
+ test_get_chunked.c
+test_get_chunked_close_string_empty_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
index b2939c8e..5744a075 100644
--- a/src/testcurl/test_get_chunked.c
+++ b/src/testcurl/test_get_chunked.c
@@ -57,6 +57,17 @@
*/
int conn_close;
+/**
+ * Use static string response instead of callback-generated?
+ */
+int resp_string;
+
+/**
+ * Use empty (zero-sized) response?
+ */
+int resp_empty;
+
+
struct headers_check_result
{
int found_chunked;
@@ -117,11 +128,12 @@ crc (void *cls,
{
struct MHD_Response **responseptr = cls;
- if (pos == 128 * 10)
+ if (resp_empty || (pos == 128 * 10))
{
- MHD_add_response_footer (*responseptr,
- RESP_FOOTER_NAME,
- RESP_FOOTER_VALUE);
+ if (MHD_YES != MHD_add_response_footer (*responseptr,
+ RESP_FOOTER_NAME,
+ RESP_FOOTER_VALUE))
+ abort ();
return MHD_CONTENT_READER_END_OF_STREAM;
}
if (max < 128)
@@ -171,20 +183,51 @@ ahc_echo (void *cls,
responseptr = malloc (sizeof (struct MHD_Response *));
if (NULL == responseptr)
_exit (99);
- response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN,
- 1024,
- &crc,
- responseptr,
- &crcf);
+ if (! resp_string)
+ {
+ response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN,
+ 1024,
+ &crc,
+ responseptr,
+ &crcf);
+ }
+ else
+ {
+ if (! resp_empty)
+ {
+ size_t pos;
+ static const size_t resp_size = 10 * 128;
+ char *buf = malloc (resp_size);
+ if (NULL == buf)
+ _exit (99);
+ for (pos = 0; pos < resp_size; pos += 128)
+ memset (buf + pos, 'A' + (pos / 128), 128);
+
+ response = MHD_create_response_from_buffer (resp_size, buf,
+ MHD_RESPMEM_MUST_COPY);
+ free (buf);
+ }
+ else
+ response = MHD_create_response_from_buffer (0, NULL,
+ MHD_RESPMEM_PERSISTENT);
+ }
if (NULL == response)
abort ();
- if (conn_close)
- { /* Enforce chunked response even for non-Keep-Alive */
+ if (conn_close || resp_string)
+ { /* Enforce chunked response even for non-Keep-Alive and static responses */
if (MHD_NO == MHD_add_response_header (response,
MHD_HTTP_HEADER_TRANSFER_ENCODING,
"chunked"))
abort ();
}
+ if (resp_string)
+ {
+ /* There is no chance to add footer later */
+ if (MHD_YES != MHD_add_response_footer (response,
+ RESP_FOOTER_NAME,
+ RESP_FOOTER_VALUE))
+ abort ();
+ }
*responseptr = response;
ret = MHD_queue_response (connection,
@@ -201,6 +244,18 @@ validate (struct CBC cbc, int ebase)
int i;
char buf[128];
+ if (resp_empty)
+ {
+ if (0 != cbc.pos)
+ {
+ fprintf (stderr,
+ "Got %u bytes instead of zero!\n",
+ (unsigned int) cbc.pos);
+ return 1;
+ }
+ return 0;
+ }
+
if (cbc.pos != 128 * 10)
{
fprintf (stderr,
@@ -666,6 +721,8 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
conn_close = has_in_name (argv[0], "_close");
+ resp_string = has_in_name (argv[0], "_string");
+ resp_empty = has_in_name (argv[0], "_empty");
if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS))
{
errorCount += testInternalGet ();
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libmicrohttpd] branch master updated: Added more tests for chunked reply encoding,
gnunet <=