gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] branch master updated (3569c42c -> fc0385be)


From: gnunet
Subject: [libmicrohttpd] branch master updated (3569c42c -> fc0385be)
Date: Thu, 06 May 2021 10:29:35 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 3569c42c -more work for JE Marchesi
     new 81bbdc70 chunked_example: enforce to use chunked encoding
     new fc0385be test_get_chunked_close: new test

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/examples/chunked_example.c  |  8 +++++
 src/testcurl/Makefile.am        |  7 ++++
 src/testcurl/test_get_chunked.c | 77 ++++++++++++++++++++++++++++++++---------
 3 files changed, 75 insertions(+), 17 deletions(-)

diff --git a/src/examples/chunked_example.c b/src/examples/chunked_example.c
index 6f449c3a..ed20d472 100644
--- a/src/examples/chunked_example.c
+++ b/src/examples/chunked_example.c
@@ -137,6 +137,14 @@ ahc_echo (void *cls,
     free (callback_param);
     return MHD_NO;
   }
+  /* Enforce chunked response, even for non-keep-alive connection. */
+  if (MHD_NO == MHD_add_response_header (response,
+                                         MHD_HTTP_HEADER_TRANSFER_ENCODING,
+                                         "chunked"))
+  {
+    free (callback_param);
+    return MHD_NO;
+  }
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
   return ret;
diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am
index 66aebe3e..b21e3ff3 100644
--- a/src/testcurl/Makefile.am
+++ b/src/testcurl/Makefile.am
@@ -99,6 +99,7 @@ check_PROGRAMS = \
   test_large_put11 \
   test_large_put_inc11 \
   test_get_chunked \
+  test_get_chunked_close \
   test_put_chunked \
   test_callback \
   $(EMPTY_ITEM)
@@ -269,6 +270,12 @@ test_get_chunked_LDADD = \
   $(top_builddir)/src/microhttpd/libmicrohttpd.la \
   @LIBCURL@
 
+test_get_chunked_close_SOURCES = \
+  test_get_chunked.c
+test_get_chunked_close_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 aa753314..2b18c50a 100644
--- a/src/testcurl/test_get_chunked.c
+++ b/src/testcurl/test_get_chunked.c
@@ -40,6 +40,8 @@
 #include <unistd.h>
 #endif
 
+#include "mhd_has_in_name.h"
+
 #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2
 #undef MHD_CPU_COUNT
 #endif
@@ -47,6 +49,11 @@
 #define MHD_CPU_COUNT 2
 #endif
 
+/**
+ * Use "Connection: close" header?
+ */
+int conn_close;
+
 struct CBC
 {
   char *buf;
@@ -135,17 +142,22 @@ ahc_echo (void *cls,
   }
   responseptr = malloc (sizeof (struct MHD_Response *));
   if (NULL == responseptr)
-    return MHD_NO;
+    _exit (99);
   response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN,
                                                 1024,
                                                 &crc,
                                                 responseptr,
                                                 &crcf);
   if (NULL == response)
-  {
-    free (responseptr);
-    return MHD_NO;
+    abort ();
+  if (conn_close)
+  { /* Enforce chunked response even for non-Keep-Alive */
+    if (MHD_NO == MHD_add_response_header (response,
+                                           MHD_HTTP_HEADER_TRANSFER_ENCODING,
+                                           "chunked"))
+      abort ();
   }
+
   *responseptr = response;
   ret = MHD_queue_response (connection,
                             MHD_HTTP_OK,
@@ -193,6 +205,7 @@ testInternalGet ()
   struct CBC cbc;
   CURLcode errornum;
   int port;
+  struct curl_slist *h_list = NULL;
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
     port = 0;
@@ -225,20 +238,26 @@ testInternalGet ()
   curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L);
   curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L);
   curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
-  /* NOTE: use of CONNECTTIMEOUT without also
-   *   setting NOSIGNAL results in really weird
-   *   crashes on my system! */
   curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
+  if (conn_close)
+  {
+    h_list = curl_slist_append (h_list, "Connection: close");
+    if (NULL == h_list)
+      abort ();
+    curl_easy_setopt (c, CURLOPT_HTTPHEADER, h_list);
+  }
   if (CURLE_OK != (errornum = curl_easy_perform (c)))
   {
     fprintf (stderr,
              "curl_easy_perform failed: `%s'\n",
              curl_easy_strerror (errornum));
     curl_easy_cleanup (c);
+    curl_slist_free_all (h_list);
     MHD_stop_daemon (d);
     return 2;
   }
   curl_easy_cleanup (c);
+  curl_slist_free_all (h_list);
   MHD_stop_daemon (d);
   return validate (cbc, 4);
 }
@@ -253,6 +272,7 @@ testMultithreadedGet ()
   struct CBC cbc;
   CURLcode errornum;
   int port;
+  struct curl_slist *h_list = NULL;
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
     port = 0;
@@ -286,20 +306,26 @@ testMultithreadedGet ()
   curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L);
   curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
   curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L);
-  /* NOTE: use of CONNECTTIMEOUT without also
-   *   setting NOSIGNAL results in really weird
-   *   crashes on my system! */
   curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
+  if (conn_close)
+  {
+    h_list = curl_slist_append (h_list, "Connection: close");
+    if (NULL == h_list)
+      abort ();
+    curl_easy_setopt (c, CURLOPT_HTTPHEADER, h_list);
+  }
   if (CURLE_OK != (errornum = curl_easy_perform (c)))
   {
     fprintf (stderr,
              "curl_easy_perform failed: `%s'\n",
              curl_easy_strerror (errornum));
     curl_easy_cleanup (c);
+    curl_slist_free_all (h_list);
     MHD_stop_daemon (d);
     return 32;
   }
   curl_easy_cleanup (c);
+  curl_slist_free_all (h_list);
   MHD_stop_daemon (d);
   return validate (cbc, 64);
 }
@@ -314,6 +340,7 @@ testMultithreadedPoolGet ()
   struct CBC cbc;
   CURLcode errornum;
   int port;
+  struct curl_slist *h_list = NULL;
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
     port = 0;
@@ -348,20 +375,26 @@ testMultithreadedPoolGet ()
   curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L);
   curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
   curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L);
-  /* NOTE: use of CONNECTTIMEOUT without also
-   *   setting NOSIGNAL results in really weird
-   *   crashes on my system! */
   curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
+  if (conn_close)
+  {
+    h_list = curl_slist_append (h_list, "Connection: close");
+    if (NULL == h_list)
+      abort ();
+    curl_easy_setopt (c, CURLOPT_HTTPHEADER, h_list);
+  }
   if (CURLE_OK != (errornum = curl_easy_perform (c)))
   {
     fprintf (stderr,
              "curl_easy_perform failed: `%s'\n",
              curl_easy_strerror (errornum));
     curl_easy_cleanup (c);
+    curl_slist_free_all (h_list);
     MHD_stop_daemon (d);
     return 32;
   }
   curl_easy_cleanup (c);
+  curl_slist_free_all (h_list);
   MHD_stop_daemon (d);
   return validate (cbc, 64);
 }
@@ -390,6 +423,7 @@ testExternalGet ()
   time_t start;
   struct timeval tv;
   int port;
+  struct curl_slist *h_list = NULL;
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
     port = 0;
@@ -423,16 +457,20 @@ testExternalGet ()
   curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
   curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L);
   curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 5L);
-  /* NOTE: use of CONNECTTIMEOUT without also
-   *   setting NOSIGNAL results in really weird
-   *   crashes on my system! */
   curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
-
+  if (conn_close)
+  {
+    h_list = curl_slist_append (h_list, "Connection: close");
+    if (NULL == h_list)
+      abort ();
+    curl_easy_setopt (c, CURLOPT_HTTPHEADER, h_list);
+  }
 
   multi = curl_multi_init ();
   if (multi == NULL)
   {
     curl_easy_cleanup (c);
+    curl_slist_free_all (h_list);
     MHD_stop_daemon (d);
     return 512;
   }
@@ -441,6 +479,7 @@ testExternalGet ()
   {
     curl_multi_cleanup (multi);
     curl_easy_cleanup (c);
+    curl_slist_free_all (h_list);
     MHD_stop_daemon (d);
     return 1024;
   }
@@ -459,6 +498,7 @@ testExternalGet ()
       curl_multi_remove_handle (multi, c);
       curl_multi_cleanup (multi);
       curl_easy_cleanup (c);
+      curl_slist_free_all (h_list);
       MHD_stop_daemon (d);
       return 2048;
     }
@@ -467,6 +507,7 @@ testExternalGet ()
       curl_multi_remove_handle (multi, c);
       curl_multi_cleanup (multi);
       curl_easy_cleanup (c);
+      curl_slist_free_all (h_list);
       MHD_stop_daemon (d);
       return 4096;
     }
@@ -513,6 +554,7 @@ testExternalGet ()
     curl_multi_remove_handle (multi, c);
     curl_easy_cleanup (c);
     curl_multi_cleanup (multi);
+    curl_slist_free_all (h_list);
   }
   MHD_stop_daemon (d);
   return validate (cbc, 8192);
@@ -527,6 +569,7 @@ main (int argc, char *const *argv)
 
   if (0 != curl_global_init (CURL_GLOBAL_WIN32))
     return 2;
+  conn_close = has_in_name (argv[0], "_close");
   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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]