aboutsummaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-02-01 09:01:10 +0000
committerChristian Grothoff <christian@grothoff.org>2013-02-01 09:01:10 +0000
commit08ce8b39168a9272276d0c50340998a64f06b4cc (patch)
tree181c0e1aa8b810e6b7d796f673ce3f98bf7e99d7 /src/daemon
parent1e5b73e684dc756cafff02817c5d4bde2330fa31 (diff)
downloadlibmicrohttpd-08ce8b39168a9272276d0c50340998a64f06b4cc.tar.gz
libmicrohttpd-08ce8b39168a9272276d0c50340998a64f06b4cc.zip
testcase for #2733
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/postprocessor_test.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/daemon/postprocessor_test.c b/src/daemon/postprocessor_test.c
index f476dae6..6042a8f4 100644
--- a/src/daemon/postprocessor_test.c
+++ b/src/daemon/postprocessor_test.c
@@ -60,6 +60,12 @@ const char *want[] = {
60 "pics", "file2.gif", "image/gif", "binary", "filedata2", 60 "pics", "file2.gif", "image/gif", "binary", "filedata2",
61#define FORM_NESTED_END (FORM_NESTED_START + 15) 61#define FORM_NESTED_END (FORM_NESTED_START + 15)
62 NULL, NULL, NULL, NULL, NULL, 62 NULL, NULL, NULL, NULL, NULL,
63#define URL_EMPTY_VALUE_DATA "key1=value1&key2="
64#define URL_EMPTY_VALUE_START (FORM_NESTED_END + 5)
65 "key1", NULL, NULL, NULL, "value1",
66 "key2", NULL, NULL, NULL, NULL,
67#define URL_EMPTY_VALUE_END (URL_EMPTY_VALUE_START + 10)
68 NULL, NULL, NULL, NULL, NULL
63}; 69};
64 70
65static int 71static int
@@ -212,6 +218,43 @@ test_nested_multipart ()
212 return 0; 218 return 0;
213} 219}
214 220
221
222static int
223test_empty_value ()
224{
225 struct MHD_Connection connection;
226 struct MHD_HTTP_Header header;
227 struct MHD_PostProcessor *pp;
228 unsigned int want_off = URL_EMPTY_VALUE_START;
229 int i;
230 int delta;
231 size_t size;
232
233 memset (&connection, 0, sizeof (struct MHD_Connection));
234 memset (&header, 0, sizeof (struct MHD_HTTP_Header));
235 connection.headers_received = &header;
236 header.header = MHD_HTTP_HEADER_CONTENT_TYPE;
237 header.value = MHD_HTTP_POST_ENCODING_FORM_URLENCODED;
238 header.kind = MHD_HEADER_KIND;
239 pp = MHD_create_post_processor (&connection,
240 1024, &value_checker, &want_off);
241 i = 0;
242 size = strlen (URL_EMPTY_VALUE_DATA);
243 while (i < size)
244 {
245 delta = 1 + RANDOM () % (size - i);
246 MHD_post_process (pp, &URL_EMPTY_VALUE_DATA[i], delta);
247 i += delta;
248 }
249 MHD_destroy_post_processor (pp);
250 if (want_off != URL_EMPTY_VALUE_END)
251 return 8;
252 return 0;
253}
254
255
256
257
215int 258int
216main (int argc, char *const *argv) 259main (int argc, char *const *argv)
217{ 260{
@@ -220,6 +263,7 @@ main (int argc, char *const *argv)
220 errorCount += test_urlencoding (); 263 errorCount += test_urlencoding ();
221 errorCount += test_multipart (); 264 errorCount += test_multipart ();
222 errorCount += test_nested_multipart (); 265 errorCount += test_nested_multipart ();
266 errorCount += test_empty_value ();
223 if (errorCount != 0) 267 if (errorCount != 0)
224 fprintf (stderr, "Error (code: %u)\n", errorCount); 268 fprintf (stderr, "Error (code: %u)\n", errorCount);
225 return errorCount != 0; /* 0 == pass */ 269 return errorCount != 0; /* 0 == pass */