gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated: test_postprocessor: test urlencod


From: gnunet
Subject: [libmicrohttpd] branch master updated: test_postprocessor: test urlencoding more thoroughly
Date: Wed, 15 Sep 2021 13:08:49 +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 292b5656 test_postprocessor: test urlencoding more thoroughly
292b5656 is described below

commit 292b565629f620d9656891186651dd2daf01242c
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed Sep 15 13:57:21 2021 +0300

    test_postprocessor: test urlencoding more thoroughly
---
 src/microhttpd/test_postprocessor.c | 99 +++++++++++++++++++------------------
 1 file changed, 50 insertions(+), 49 deletions(-)

diff --git a/src/microhttpd/test_postprocessor.c 
b/src/microhttpd/test_postprocessor.c
index 4071e939..08464d38 100644
--- a/src/microhttpd/test_postprocessor.c
+++ b/src/microhttpd/test_postprocessor.c
@@ -197,59 +197,60 @@ test_urlencoding_case (unsigned int want_start,
                        unsigned int want_end,
                        const char *url_data)
 {
-  struct MHD_Connection connection;
-  struct MHD_HTTP_Header header;
-  struct MHD_PostProcessor *pp;
-  unsigned int want_off = want_start;
-  size_t i;
-  size_t delta;
-  size_t size;
+  size_t step;
+  const size_t size = strlen (url_data);
 
-  memset (&connection, 0, sizeof (struct MHD_Connection));
-  memset (&header, 0, sizeof (struct MHD_HTTP_Header));
-  connection.headers_received = &header;
-  header.header = MHD_HTTP_HEADER_CONTENT_TYPE;
-  header.value = MHD_HTTP_POST_ENCODING_FORM_URLENCODED;
-  header.header_size = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_TYPE);
-  header.value_size = MHD_STATICSTR_LEN_ (
-    MHD_HTTP_POST_ENCODING_FORM_URLENCODED);
-  header.kind = MHD_HEADER_KIND;
-  pp = MHD_create_post_processor (&connection,
-                                  1024,
-                                  &value_checker,
-                                  &want_off);
-  if (NULL == pp)
-  {
-    fprintf (stderr, "Failed to create post processor.\n"
-             "Line: %u\n", (unsigned int) __LINE__);
-    exit (50);
-  }
-  i = 0;
-  size = strlen (url_data);
-  while (i < size)
+  for (step = 1; size >= step; ++step)
   {
-    delta = 1 + MHD_random_ () % (size - i);
-    if (MHD_YES != MHD_post_process (pp,
-                                     &url_data[i],
-                                     delta))
+    struct MHD_Connection connection;
+    struct MHD_HTTP_Header header;
+    struct MHD_PostProcessor *pp;
+    unsigned int want_off = want_start;
+    size_t i;
+
+    memset (&connection, 0, sizeof (struct MHD_Connection));
+    memset (&header, 0, sizeof (struct MHD_HTTP_Header));
+    connection.headers_received = &header;
+    header.header = MHD_HTTP_HEADER_CONTENT_TYPE;
+    header.value = MHD_HTTP_POST_ENCODING_FORM_URLENCODED;
+    header.header_size = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_TYPE);
+    header.value_size =
+      MHD_STATICSTR_LEN_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED);
+    header.kind = MHD_HEADER_KIND;
+    pp = MHD_create_post_processor (&connection,
+                                    1024,
+                                    &value_checker,
+                                    &want_off);
+    if (NULL == pp)
     {
-      fprintf (stderr, "Failed to process the data.\n"
-               "i: %u. delta: %u.\n"
-               "Line: %u\n", (unsigned) i, (unsigned) delta,
-               (unsigned int) __LINE__);
-      exit (49);
+      fprintf (stderr, "Failed to create post processor.\n"
+               "Line: %u\n", (unsigned int) __LINE__);
+      exit (50);
+    }
+    for (i = 0; size > i; i += step)
+    {
+      size_t left = size - i;
+      if (MHD_YES != MHD_post_process (pp,
+                                       &url_data[i],
+                                       (left > step) ? step : left))
+      {
+        fprintf (stderr, "Failed to process the data.\n"
+                 "i: %u. step: %u.\n"
+                 "Line: %u\n", (unsigned) i, (unsigned) step,
+                 (unsigned int) __LINE__);
+        exit (49);
+      }
+    }
+    MHD_destroy_post_processor (pp);
+    if (want_off != want_end)
+    {
+      fprintf (stderr,
+               "Test failed in line %u: %u != %u\n",
+               (unsigned int) __LINE__,
+               want_off,
+               want_end);
+      return 1;
     }
-    i += delta;
-  }
-  MHD_destroy_post_processor (pp);
-  if (want_off != want_end)
-  {
-    fprintf (stderr,
-             "Test failed in line %u: %u != %u\n",
-             (unsigned int) __LINE__,
-             want_off,
-             want_end);
-    return 1;
   }
   return 0;
 }

-- 
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]