@@ -60,6 +60,12 @@ const char *want[] = {
60
60
"pics" , "file2.gif" , "image/gif" , "binary" , "filedata2" ,
61
61
#define FORM_NESTED_END (FORM_NESTED_START + 15 )
62
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
65
71
static int
@@ -212,6 +218,43 @@ test_nested_multipart ()
212
218
return 0 ;
213
219
}
214
220
221
+
222
+ static int
223
+ test_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
+
215
258
int
216
259
main (int argc , char * const * argv )
217
260
{
@@ -220,6 +263,7 @@ main (int argc, char *const *argv)
220
263
errorCount += test_urlencoding ();
221
264
errorCount += test_multipart ();
222
265
errorCount += test_nested_multipart ();
266
+ errorCount += test_empty_value ();
223
267
if (errorCount != 0 )
224
268
fprintf (stderr , "Error (code: %u)\n" , errorCount );
225
269
return errorCount != 0 ; /* 0 == pass */
0 commit comments