aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/test_parse_cookies.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/test_parse_cookies.c')
-rw-r--r--src/testcurl/test_parse_cookies.c540
1 files changed, 496 insertions, 44 deletions
diff --git a/src/testcurl/test_parse_cookies.c b/src/testcurl/test_parse_cookies.c
index 987ddbf4..308b751e 100644
--- a/src/testcurl/test_parse_cookies.c
+++ b/src/testcurl/test_parse_cookies.c
@@ -189,7 +189,7 @@ _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum)
189 189
190 190
191/* Could be increased to facilitate debugging */ 191/* Could be increased to facilitate debugging */
192#define TIMEOUTS_VAL 5 192#define TIMEOUTS_VAL 500000
193 193
194#define EXPECTED_URI_BASE_PATH "/" 194#define EXPECTED_URI_BASE_PATH "/"
195 195
@@ -203,6 +203,9 @@ _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum)
203 "<html><head><title>libmicrohttpd test page</title></head>" \ 203 "<html><head><title>libmicrohttpd test page</title></head>" \
204 "<body>Success!</body></html>" 204 "<body>Success!</body></html>"
205 205
206#define PAGE_ERROR \
207 "<html><body>Cookies parsing error</body></html>"
208
206 209
207#ifndef MHD_STATICSTR_LEN_ 210#ifndef MHD_STATICSTR_LEN_
208/** 211/**
@@ -234,19 +237,293 @@ struct strct_test_data
234{ 237{
235 unsigned int line_num; 238 unsigned int line_num;
236 const char *header_str; 239 const char *header_str;
237 unsigned int num_cookies_non_strict; 240 unsigned int num_cookies_strict_p2; /* Reserved */
238 unsigned int num_cookies_strict; 241 unsigned int num_cookies_strict_p1;
242 unsigned int num_cookies_strict_zero;
243 unsigned int num_cookies_strict_n1;
239 struct strct_cookie cookies[5]; 244 struct strct_cookie cookies[5];
240}; 245};
241 246
242static const struct strct_test_data test_data[] = { 247static const struct strct_test_data test_data[] = {
243 { 248 {
244 __LINE__, 249 __LINE__,
250 "name1=value1",
251 1,
252 1,
253 1,
254 1,
255 {
256 COOKIE_ ("name1", "value1"),
257 COOKIE_NULL,
258 COOKIE_NULL,
259 COOKIE_NULL,
260 COOKIE_NULL
261 }
262 },
263 {
264 __LINE__,
265 "name1=value1;",
266 1,
267 1,
268 1,
269 1,
270 {
271 COOKIE_ ("name1", "value1"),
272 COOKIE_NULL,
273 COOKIE_NULL,
274 COOKIE_NULL,
275 COOKIE_NULL
276 }
277 },
278 {
279 __LINE__,
280 "name1=value1; ",
281 0,
282 1,
283 1,
284 1,
285 {
286 COOKIE_ ("name1", "value1"),
287 COOKIE_NULL,
288 COOKIE_NULL,
289 COOKIE_NULL,
290 COOKIE_NULL
291 }
292 },
293 {
294 __LINE__,
295 "; name1=value1",
296 0,
297 0,
298 1,
299 1,
300 {
301 COOKIE_ ("name1", "value1"),
302 COOKIE_NULL,
303 COOKIE_NULL,
304 COOKIE_NULL,
305 COOKIE_NULL
306 }
307 },
308 {
309 __LINE__,
310 ";name1=value1",
311 0,
312 0,
313 1,
314 1,
315 {
316 COOKIE_ ("name1", "value1"),
317 COOKIE_NULL,
318 COOKIE_NULL,
319 COOKIE_NULL,
320 COOKIE_NULL
321 }
322 },
323 {
324 __LINE__,
325 "name1=value1 ",
326 1,
327 1,
328 1,
329 1,
330 {
331 COOKIE_ ("name1", "value1"),
332 COOKIE_NULL,
333 COOKIE_NULL,
334 COOKIE_NULL,
335 COOKIE_NULL
336 }
337 },
338 {
339 __LINE__,
340 "name1=value1 ;",
341 0,
342 0,
343 1,
344 1,
345 {
346 COOKIE_ ("name1", "value1"),
347 COOKIE_NULL,
348 COOKIE_NULL,
349 COOKIE_NULL,
350 COOKIE_NULL
351 }
352 },
353 {
354 __LINE__,
355 "name1=value1 ; ",
356 0,
357 0,
358 1,
359 1,
360 {
361 COOKIE_ ("name1", "value1"),
362 COOKIE_NULL,
363 COOKIE_NULL,
364 COOKIE_NULL,
365 COOKIE_NULL
366 }
367 },
368 {
369 __LINE__,
370 "name2=\"value 2\"",
371 0,
372 0,
373 1,
374 1,
375 {
376 COOKIE_ ("name2", "value 2"),
377 COOKIE_NULL,
378 COOKIE_NULL,
379 COOKIE_NULL,
380 COOKIE_NULL
381 }
382 },
383 {
384 __LINE__,
385 "name1=value1;\tname2=value2",
386 0,
387 1,
388 2,
389 2,
390 {
391 COOKIE_ ("name1", "value1"),
392 COOKIE_ ("name2", "value2"),
393 COOKIE_NULL,
394 COOKIE_NULL,
395 COOKIE_NULL
396 }
397 },
398 {
399 __LINE__,
400 "name1=value1; name1=value1",
401 2,
402 2,
403 2,
404 2,
405 {
406 COOKIE_ ("name1", "value1"),
407 COOKIE_ ("name1", "value1"),
408 COOKIE_NULL,
409 COOKIE_NULL,
410 COOKIE_NULL
411 }
412 },
413 {
414 __LINE__,
415 "name1=value1; name2=value2",
416 2,
417 2,
418 2,
419 2,
420 {
421 COOKIE_ ("name1", "value1"),
422 COOKIE_ ("name2", "value2"),
423 COOKIE_NULL,
424 COOKIE_NULL,
425 COOKIE_NULL
426 }
427 },
428 {
429 __LINE__,
430 "name1=value1; name2=value2",
431 2,
432 2,
433 2,
434 2,
435 {
436 COOKIE_ ("name1", "value1"),
437 COOKIE_ ("name2", "value2"),
438 COOKIE_NULL,
439 COOKIE_NULL,
440 COOKIE_NULL
441 }
442 },
443 {
444 __LINE__,
445 "name1=value1; name2=value2",
446 2,
447 2,
448 2,
449 2,
450 {
451 COOKIE_ ("name1", "value1"),
452 COOKIE_ ("name2", "value2"),
453 COOKIE_NULL,
454 COOKIE_NULL,
455 COOKIE_NULL
456 }
457 },
458 {
459 __LINE__,
460 "name1=value1; name2=value2",
461 2,
462 2,
463 2,
464 2,
465 {
466 COOKIE_ ("name1", "value1"),
467 COOKIE_ ("name2", "value2"),
468 COOKIE_NULL,
469 COOKIE_NULL,
470 COOKIE_NULL
471 }
472 },
473 {
474 __LINE__,
475 "name1=value1; name2=value2",
476 2,
477 2,
478 2,
479 2,
480 {
481 COOKIE_ ("name1", "value1"),
482 COOKIE_ ("name2", "value2"),
483 COOKIE_NULL,
484 COOKIE_NULL,
485 COOKIE_NULL
486 }
487 },
488 {
489 __LINE__,
490 "name1=value1; name2=value2",
491 2,
492 2,
493 2,
494 2,
495 {
496 COOKIE_ ("name1", "value1"),
497 COOKIE_ ("name2", "value2"),
498 COOKIE_NULL,
499 COOKIE_NULL,
500 COOKIE_NULL
501 }
502 },
503 {
504 __LINE__,
505 "name1=value1; name2=value2",
506 2,
507 2,
508 2,
509 2,
510 {
511 COOKIE_ ("name1", "value1"),
512 COOKIE_ ("name2", "value2"),
513 COOKIE_NULL,
514 COOKIE_NULL,
515 COOKIE_NULL
516 }
517 },
518 {
519 __LINE__,
245 "name1=var1; name2=var2; name3=; " \ 520 "name1=var1; name2=var2; name3=; " \
246 "name4=\"var4 with spaces\"; " \ 521 "name4=\"var4 with spaces\"; " \
247 "name5=var_with_=_char", 522 "name5=var_with_=_char",
248 5,
249 0, 523 0,
524 3,
525 5,
526 5,
250 { 527 {
251 COOKIE_ ("name1", "var1"), 528 COOKIE_ ("name1", "var1"),
252 COOKIE_ ("name2", "var2"), 529 COOKIE_ ("name2", "var2"),
@@ -260,8 +537,10 @@ static const struct strct_test_data test_data[] = {
260 "name1=var1;name2=var2;name3=;" \ 537 "name1=var1;name2=var2;name3=;" \
261 "name4=\"var4 with spaces\";" \ 538 "name4=\"var4 with spaces\";" \
262 "name5=var_with_=_char", 539 "name5=var_with_=_char",
263 5,
264 0, 540 0,
541 1,
542 5,
543 5,
265 { 544 {
266 COOKIE_ ("name1", "var1"), 545 COOKIE_ ("name1", "var1"),
267 COOKIE_ ("name2", "var2"), 546 COOKIE_ ("name2", "var2"),
@@ -275,8 +554,10 @@ static const struct strct_test_data test_data[] = {
275 "name1=var1; name2=var2; name3=; " \ 554 "name1=var1; name2=var2; name3=; " \
276 "name4=\"var4 with spaces\"; " \ 555 "name4=\"var4 with spaces\"; " \
277 "name5=var_with_=_char\t \t", 556 "name5=var_with_=_char\t \t",
278 5,
279 0, 557 0,
558 1,
559 5,
560 5,
280 { 561 {
281 COOKIE_ ("name1", "var1"), 562 COOKIE_ ("name1", "var1"),
282 COOKIE_ ("name2", "var2"), 563 COOKIE_ ("name2", "var2"),
@@ -290,8 +571,10 @@ static const struct strct_test_data test_data[] = {
290 "name1=var1;;name2=var2;;name3=;;" \ 571 "name1=var1;;name2=var2;;name3=;;" \
291 "name4=\"var4 with spaces\";;" \ 572 "name4=\"var4 with spaces\";;" \
292 "name5=var_with_=_char;\t \t", 573 "name5=var_with_=_char;\t \t",
293 5,
294 0, 574 0,
575 1,
576 5,
577 5,
295 { 578 {
296 COOKIE_ ("name1", "var1"), 579 COOKIE_ ("name1", "var1"),
297 COOKIE_ ("name2", "var2"), 580 COOKIE_ ("name2", "var2"),
@@ -305,14 +588,16 @@ static const struct strct_test_data test_data[] = {
305 "name3=; name1=var1; name2=var2; " \ 588 "name3=; name1=var1; name2=var2; " \
306 "name5=var_with_=_char;" \ 589 "name5=var_with_=_char;" \
307 "name4=\"var4 with spaces\"", 590 "name4=\"var4 with spaces\"",
308 5,
309 0, 591 0,
592 4,
593 5,
594 5,
310 { 595 {
311 COOKIE_ ("name1", "var1"), 596 COOKIE_ ("name1", "var1"),
312 COOKIE_ ("name2", "var2"), 597 COOKIE_ ("name2", "var2"),
313 COOKIE_ ("name3", ""), 598 COOKIE_ ("name3", ""),
314 COOKIE_ ("name4", "var4 with spaces"), 599 COOKIE_ ("name5", "var_with_=_char"),
315 COOKIE_ ("name5", "var_with_=_char") 600 COOKIE_ ("name4", "var4 with spaces")
316 } 601 }
317 }, 602 },
318 { 603 {
@@ -320,14 +605,16 @@ static const struct strct_test_data test_data[] = {
320 "name2=var2; name1=var1; " \ 605 "name2=var2; name1=var1; " \
321 "name5=var_with_=_char; name3=; " \ 606 "name5=var_with_=_char; name3=; " \
322 "name4=\"var4 with spaces\";", 607 "name4=\"var4 with spaces\";",
323 5,
324 0, 608 0,
609 4,
610 5,
611 5,
325 { 612 {
326 COOKIE_ ("name1", "var1"), 613 COOKIE_ ("name1", "var1"),
327 COOKIE_ ("name2", "var2"), 614 COOKIE_ ("name2", "var2"),
328 COOKIE_ ("name3", ""), 615 COOKIE_ ("name3", ""),
329 COOKIE_ ("name4", "var4 with spaces"), 616 COOKIE_ ("name5", "var_with_=_char"),
330 COOKIE_ ("name5", "var_with_=_char") 617 COOKIE_ ("name4", "var4 with spaces")
331 } 618 }
332 }, 619 },
333 { 620 {
@@ -335,14 +622,16 @@ static const struct strct_test_data test_data[] = {
335 "name2=var2; name1=var1; " \ 622 "name2=var2; name1=var1; " \
336 "name5=var_with_=_char; " \ 623 "name5=var_with_=_char; " \
337 "name4=\"var4 with spaces\"; name3=", 624 "name4=\"var4 with spaces\"; name3=",
338 5,
339 0, 625 0,
626 3,
627 5,
628 5,
340 { 629 {
341 COOKIE_ ("name1", "var1"), 630 COOKIE_ ("name1", "var1"),
342 COOKIE_ ("name2", "var2"), 631 COOKIE_ ("name2", "var2"),
632 COOKIE_ ("name5", "var_with_=_char"),
343 COOKIE_ ("name3", ""), 633 COOKIE_ ("name3", ""),
344 COOKIE_ ("name4", "var4 with spaces"), 634 COOKIE_ ("name4", "var4 with spaces")
345 COOKIE_ ("name5", "var_with_=_char")
346 } 635 }
347 }, 636 },
348 { 637 {
@@ -350,8 +639,10 @@ static const struct strct_test_data test_data[] = {
350 "name2=var2; name1=var1; " \ 639 "name2=var2; name1=var1; " \
351 "name4=\"var4 with spaces\"; " \ 640 "name4=\"var4 with spaces\"; " \
352 "name5=var_with_=_char; name3=;", 641 "name5=var_with_=_char; name3=;",
353 5,
354 0, 642 0,
643 2,
644 5,
645 5,
355 { 646 {
356 COOKIE_ ("name1", "var1"), 647 COOKIE_ ("name1", "var1"),
357 COOKIE_ ("name2", "var2"), 648 COOKIE_ ("name2", "var2"),
@@ -365,8 +656,10 @@ static const struct strct_test_data test_data[] = {
365 ";;;;;;;;name1=var1; name2=var2; name3=; " \ 656 ";;;;;;;;name1=var1; name2=var2; name3=; " \
366 "name4=\"var4 with spaces\"; " \ 657 "name4=\"var4 with spaces\"; " \
367 "name5=var_with_=_char", 658 "name5=var_with_=_char",
368 5,
369 0, 659 0,
660 0,
661 5,
662 5,
370 { 663 {
371 COOKIE_ ("name1", "var1"), 664 COOKIE_ ("name1", "var1"),
372 COOKIE_ ("name2", "var2"), 665 COOKIE_ ("name2", "var2"),
@@ -380,8 +673,10 @@ static const struct strct_test_data test_data[] = {
380 "name1=var1; name2=var2; name3=; " \ 673 "name1=var1; name2=var2; name3=; " \
381 "name4=\"var4 with spaces\"; ; ; ; ; " \ 674 "name4=\"var4 with spaces\"; ; ; ; ; " \
382 "name5=var_with_=_char", 675 "name5=var_with_=_char",
383 5,
384 0, 676 0,
677 3,
678 5,
679 5,
385 { 680 {
386 COOKIE_ ("name1", "var1"), 681 COOKIE_ ("name1", "var1"),
387 COOKIE_ ("name2", "var2"), 682 COOKIE_ ("name2", "var2"),
@@ -395,8 +690,10 @@ static const struct strct_test_data test_data[] = {
395 "name1=var1; name2=var2; name3=; " \ 690 "name1=var1; name2=var2; name3=; " \
396 "name4=\"var4 with spaces\"; " \ 691 "name4=\"var4 with spaces\"; " \
397 "name5=var_with_=_char;;;;;;;;", 692 "name5=var_with_=_char;;;;;;;;",
398 5,
399 0, 693 0,
694 3,
695 5,
696 5,
400 { 697 {
401 COOKIE_ ("name1", "var1"), 698 COOKIE_ ("name1", "var1"),
402 COOKIE_ ("name2", "var2"), 699 COOKIE_ ("name2", "var2"),
@@ -408,16 +705,18 @@ static const struct strct_test_data test_data[] = {
408 { 705 {
409 __LINE__, 706 __LINE__,
410 "name1=var1; name2=var2; " \ 707 "name1=var1; name2=var2; " \
411 "name4=\"var4 with spaces\"" \ 708 "name4=\"var4 with spaces\";" \
412 "name5=var_with_=_char; ; ; ; ; name3=", 709 "name5=var_with_=_char; ; ; ; ; name3=",
413 5,
414 0, 710 0,
711 2,
712 5,
713 5,
415 { 714 {
416 COOKIE_ ("name1", "var1"), 715 COOKIE_ ("name1", "var1"),
417 COOKIE_ ("name2", "var2"), 716 COOKIE_ ("name2", "var2"),
717 COOKIE_ ("name5", "var_with_=_char"),
418 COOKIE_ ("name3", ""), 718 COOKIE_ ("name3", ""),
419 COOKIE_ ("name4", "var4 with spaces"), 719 COOKIE_ ("name4", "var4 with spaces")
420 COOKIE_ ("name5", "var_with_=_char")
421 } 720 }
422 }, 721 },
423 { 722 {
@@ -425,8 +724,10 @@ static const struct strct_test_data test_data[] = {
425 "name5=var_with_=_char ;" \ 724 "name5=var_with_=_char ;" \
426 "name1=var1; name2=var2; name3=; " \ 725 "name1=var1; name2=var2; name3=; " \
427 "name4=\"var4 with spaces\" ", 726 "name4=\"var4 with spaces\" ",
428 5,
429 0, 727 0,
728 0,
729 5,
730 5,
430 { 731 {
431 COOKIE_ ("name1", "var1"), 732 COOKIE_ ("name1", "var1"),
432 COOKIE_ ("name2", "var2"), 733 COOKIE_ ("name2", "var2"),
@@ -439,14 +740,106 @@ static const struct strct_test_data test_data[] = {
439 __LINE__, 740 __LINE__,
440 "name5=var_with_=_char; name4=\"var4 with spaces\";" \ 741 "name5=var_with_=_char; name4=\"var4 with spaces\";" \
441 "name1=var1; name2=var2; name3=", 742 "name1=var1; name2=var2; name3=",
442 5,
443 0, 743 0,
744 1,
745 5,
746 5,
444 { 747 {
748 COOKIE_ ("name5", "var_with_=_char"),
445 COOKIE_ ("name1", "var1"), 749 COOKIE_ ("name1", "var1"),
446 COOKIE_ ("name2", "var2"), 750 COOKIE_ ("name2", "var2"),
447 COOKIE_ ("name3", ""), 751 COOKIE_ ("name3", ""),
448 COOKIE_ ("name4", "var4 with spaces"), 752 COOKIE_ ("name4", "var4 with spaces")
449 COOKIE_ ("name5", "var_with_=_char") 753 }
754 },
755 {
756 __LINE__,
757 "name1 = value1",
758 0,
759 0,
760 0,
761 1,
762 {
763 COOKIE_ ("name1", "value1"),
764 COOKIE_NULL,
765 COOKIE_NULL,
766 COOKIE_NULL,
767 COOKIE_NULL
768 }
769 },
770 {
771 __LINE__,
772 "name1\t=\tvalue1",
773 0,
774 0,
775 0,
776 1,
777 {
778 COOKIE_ ("name1", "value1"),
779 COOKIE_NULL,
780 COOKIE_NULL,
781 COOKIE_NULL,
782 COOKIE_NULL
783 }
784 },
785 {
786 __LINE__,
787 "name1\t = \tvalue1",
788 0,
789 0,
790 0,
791 1,
792 {
793 COOKIE_ ("name1", "value1"),
794 COOKIE_NULL,
795 COOKIE_NULL,
796 COOKIE_NULL,
797 COOKIE_NULL
798 }
799 },
800 {
801 __LINE__,
802 "name1 = value1; name2 =\tvalue2",
803 0,
804 0,
805 0,
806 2,
807 {
808 COOKIE_ ("name1", "value1"),
809 COOKIE_ ("name2", "value2"),
810 COOKIE_NULL,
811 COOKIE_NULL,
812 COOKIE_NULL
813 }
814 },
815 {
816 __LINE__,
817 "name1=value1; name2 =\tvalue2",
818 0,
819 1,
820 1,
821 2,
822 {
823 COOKIE_ ("name1", "value1"),
824 COOKIE_ ("name2", "value2"),
825 COOKIE_NULL,
826 COOKIE_NULL,
827 COOKIE_NULL
828 }
829 },
830 {
831 __LINE__,
832 "name1 = value1; name2=value2",
833 0,
834 0,
835 0,
836 2,
837 {
838 COOKIE_ ("name1", "value1"),
839 COOKIE_ ("name2", "value2"),
840 COOKIE_NULL,
841 COOKIE_NULL,
842 COOKIE_NULL
450 } 843 }
451 }, 844 },
452 { 845 {
@@ -454,6 +847,8 @@ static const struct strct_test_data test_data[] = {
454 "", 847 "",
455 0, 848 0,
456 0, 849 0,
850 0,
851 0,
457 { 852 {
458 COOKIE_NULL, 853 COOKIE_NULL,
459 COOKIE_NULL, 854 COOKIE_NULL,
@@ -467,6 +862,8 @@ static const struct strct_test_data test_data[] = {
467 " ", 862 " ",
468 0, 863 0,
469 0, 864 0,
865 0,
866 0,
470 { 867 {
471 COOKIE_NULL, 868 COOKIE_NULL,
472 COOKIE_NULL, 869 COOKIE_NULL,
@@ -480,6 +877,8 @@ static const struct strct_test_data test_data[] = {
480 "\t", 877 "\t",
481 0, 878 0,
482 0, 879 0,
880 0,
881 0,
483 { 882 {
484 COOKIE_NULL, 883 COOKIE_NULL,
485 COOKIE_NULL, 884 COOKIE_NULL,
@@ -493,6 +892,8 @@ static const struct strct_test_data test_data[] = {
493 "var=,", 892 "var=,",
494 0, 893 0,
495 0, 894 0,
895 0,
896 0,
496 { 897 {
497 COOKIE_NULL, 898 COOKIE_NULL,
498 COOKIE_NULL, 899 COOKIE_NULL,
@@ -506,6 +907,8 @@ static const struct strct_test_data test_data[] = {
506 "var=\"\\ \"", 907 "var=\"\\ \"",
507 0, 908 0,
508 0, 909 0,
910 0,
911 0,
509 { 912 {
510 COOKIE_NULL, 913 COOKIE_NULL,
511 COOKIE_NULL, 914 COOKIE_NULL,
@@ -519,6 +922,8 @@ static const struct strct_test_data test_data[] = {
519 "var=value space", 922 "var=value space",
520 0, 923 0,
521 0, 924 0,
925 0,
926 0,
522 { 927 {
523 COOKIE_NULL, 928 COOKIE_NULL,
524 COOKIE_NULL, 929 COOKIE_NULL,
@@ -532,6 +937,8 @@ static const struct strct_test_data test_data[] = {
532 "var=value\ttab", 937 "var=value\ttab",
533 0, 938 0,
534 0, 939 0,
940 0,
941 0,
535 { 942 {
536 COOKIE_NULL, 943 COOKIE_NULL,
537 COOKIE_NULL, 944 COOKIE_NULL,
@@ -545,6 +952,8 @@ static const struct strct_test_data test_data[] = {
545 "=", 952 "=",
546 0, 953 0,
547 0, 954 0,
955 0,
956 0,
548 { 957 {
549 COOKIE_NULL, 958 COOKIE_NULL,
550 COOKIE_NULL, 959 COOKIE_NULL,
@@ -558,6 +967,8 @@ static const struct strct_test_data test_data[] = {
558 "====", 967 "====",
559 0, 968 0,
560 0, 969 0,
970 0,
971 0,
561 { 972 {
562 COOKIE_NULL, 973 COOKIE_NULL,
563 COOKIE_NULL, 974 COOKIE_NULL,
@@ -571,6 +982,8 @@ static const struct strct_test_data test_data[] = {
571 ";=", 982 ";=",
572 0, 983 0,
573 0, 984 0,
985 0,
986 0,
574 { 987 {
575 COOKIE_NULL, 988 COOKIE_NULL,
576 COOKIE_NULL, 989 COOKIE_NULL,
@@ -584,6 +997,8 @@ static const struct strct_test_data test_data[] = {
584 "var", 997 "var",
585 0, 998 0,
586 0, 999 0,
1000 0,
1001 0,
587 { 1002 {
588 COOKIE_NULL, 1003 COOKIE_NULL,
589 COOKIE_NULL, 1004 COOKIE_NULL,
@@ -597,6 +1012,8 @@ static const struct strct_test_data test_data[] = {
597 "=;", 1012 "=;",
598 0, 1013 0,
599 0, 1014 0,
1015 0,
1016 0,
600 { 1017 {
601 COOKIE_NULL, 1018 COOKIE_NULL,
602 COOKIE_NULL, 1019 COOKIE_NULL,
@@ -610,6 +1027,8 @@ static const struct strct_test_data test_data[] = {
610 "= ;", 1027 "= ;",
611 0, 1028 0,
612 0, 1029 0,
1030 0,
1031 0,
613 { 1032 {
614 COOKIE_NULL, 1033 COOKIE_NULL,
615 COOKIE_NULL, 1034 COOKIE_NULL,
@@ -623,6 +1042,8 @@ static const struct strct_test_data test_data[] = {
623 ";= ;", 1042 ";= ;",
624 0, 1043 0,
625 0, 1044 0,
1045 0,
1046 0,
626 { 1047 {
627 COOKIE_NULL, 1048 COOKIE_NULL,
628 COOKIE_NULL, 1049 COOKIE_NULL,
@@ -636,7 +1057,10 @@ static const struct strct_test_data test_data[] = {
636/* Global parameters */ 1057/* Global parameters */
637static int verbose; 1058static int verbose;
638static int oneone; /**< If false use HTTP/1.0 for requests*/ 1059static int oneone; /**< If false use HTTP/1.0 for requests*/
639static int use_non_strict; 1060static int use_strict_n1;
1061static int use_strict_zero;
1062static int use_strict_p1;
1063static int strict_level;
640 1064
641static void 1065static void
642test_global_init (void) 1066test_global_init (void)
@@ -700,12 +1124,19 @@ ahcCheck (void *cls,
700 struct MHD_Response *response; 1124 struct MHD_Response *response;
701 enum MHD_Result ret; 1125 enum MHD_Result ret;
702 struct ahc_cls_type *const param = (struct ahc_cls_type *) cls; 1126 struct ahc_cls_type *const param = (struct ahc_cls_type *) cls;
703 const unsigned int expected_num_cookies = 1127 unsigned int expected_num_cookies;
704 use_non_strict ? param->check->num_cookies_non_strict :
705 param->check->num_cookies_strict;
706 unsigned int i; 1128 unsigned int i;
707 int cookie_failed; 1129 int cookie_failed;
708 1130
1131 if (use_strict_p1)
1132 expected_num_cookies = param->check->num_cookies_strict_p1;
1133 else if (use_strict_zero)
1134 expected_num_cookies = param->check->num_cookies_strict_zero;
1135 else if (use_strict_n1)
1136 expected_num_cookies = param->check->num_cookies_strict_n1;
1137 else
1138 externalErrorExit ();
1139
709 if (NULL == param) 1140 if (NULL == param)
710 mhdErrorExitDesc ("cls parameter is NULL"); 1141 mhdErrorExitDesc ("cls parameter is NULL");
711 1142
@@ -813,7 +1244,17 @@ ahcCheck (void *cls,
813 cookie_failed = 1; 1244 cookie_failed = 1;
814 } 1245 }
815 if (cookie_failed) 1246 if (cookie_failed)
816 return MHD_NO; /* Break connection */ 1247 {
1248 response =
1249 MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE_ERROR),
1250 PAGE_ERROR);
1251 ret = MHD_queue_response (connection,
1252 MHD_HTTP_BAD_REQUEST,
1253 response);
1254 MHD_destroy_response (response);
1255
1256 return ret;
1257 }
817 1258
818 if (&marker != *req_cls) 1259 if (&marker != *req_cls)
819 { 1260 {
@@ -1057,7 +1498,6 @@ check_result (CURLcode curl_code, CURL *c, long expected_code,
1057 struct CBC *pcbc) 1498 struct CBC *pcbc)
1058{ 1499{
1059 long code; 1500 long code;
1060 unsigned int ret;
1061 1501
1062 if (CURLE_OK != curl_code) 1502 if (CURLE_OK != curl_code)
1063 { 1503 {
@@ -1079,15 +1519,15 @@ check_result (CURLcode curl_code, CURL *c, long expected_code,
1079 if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code)) 1519 if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code))
1080 libcurlErrorExit (); 1520 libcurlErrorExit ();
1081 1521
1082 ret = 1;
1083 if (expected_code != code) 1522 if (expected_code != code)
1084 { 1523 {
1085 fprintf (stderr, "The response has wrong HTTP code: %ld\tExpected: %ld.\n", 1524 fprintf (stderr, "### The response has wrong HTTP code: %ld\t"
1525 "Expected: %ld.\n",
1086 code, expected_code); 1526 code, expected_code);
1087 ret = 0; 1527 return 0;
1088 } 1528 }
1089 else if (verbose) 1529 else if (verbose)
1090 printf ("The response has expected HTTP code: %ld\n", expected_code); 1530 printf ("### The response has expected HTTP code: %ld\n", expected_code);
1091 1531
1092 if (pcbc->pos != MHD_STATICSTR_LEN_ (PAGE)) 1532 if (pcbc->pos != MHD_STATICSTR_LEN_ (PAGE))
1093 { 1533 {
@@ -1105,7 +1545,7 @@ check_result (CURLcode curl_code, CURL *c, long expected_code,
1105 fflush (stderr); 1545 fflush (stderr);
1106 fflush (stdout); 1546 fflush (stdout);
1107 1547
1108 return ret; 1548 return 1;
1109} 1549}
1110 1550
1111 1551
@@ -1125,13 +1565,13 @@ testExternalPolling (void)
1125 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 1565 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
1126 port = 0; 1566 port = 0;
1127 else 1567 else
1128 port = 1340 + oneone ? 0 : 1 + use_non_strict ? 0 : 2; 1568 port = 1340 + oneone ? 0 : 6 + (uint16_t) (1 + strict_level);
1129 1569
1130 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 1570 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
1131 port, NULL, NULL, 1571 port, NULL, NULL,
1132 &ahcCheck, &ahc_param, 1572 &ahcCheck, &ahc_param,
1133 MHD_OPTION_STRICT_FOR_CLIENT, 1573 MHD_OPTION_STRICT_FOR_CLIENT,
1134 (int) (use_non_strict ? 0 : 1), 1574 (int) (strict_level),
1135 MHD_OPTION_END); 1575 MHD_OPTION_END);
1136 if (d == NULL) 1576 if (d == NULL)
1137 return 1; 1577 return 1;
@@ -1167,13 +1607,13 @@ testExternalPolling (void)
1167 MHD_HTTP_OK, &cbc)) 1607 MHD_HTTP_OK, &cbc))
1168 { 1608 {
1169 if (verbose) 1609 if (verbose)
1170 printf ("Got expected response for the check at line %u.\n", 1610 printf ("### Got expected response for the check at line %u.\n",
1171 test_data[i].line_num); 1611 test_data[i].line_num);
1172 fflush (stdout); 1612 fflush (stdout);
1173 } 1613 }
1174 else 1614 else
1175 { 1615 {
1176 fprintf (stderr, "FAILED request for the check at line %u.\n", 1616 fprintf (stderr, "### FAILED request for the check at line %u.\n",
1177 test_data[i].line_num); 1617 test_data[i].line_num);
1178 fflush (stderr); 1618 fflush (stderr);
1179 failed = 1; 1619 failed = 1;
@@ -1200,7 +1640,19 @@ main (int argc, char *const *argv)
1200 has_param (argc, argv, "-s") || 1640 has_param (argc, argv, "-s") ||
1201 has_param (argc, argv, "--silent")); 1641 has_param (argc, argv, "--silent"));
1202 oneone = ! has_in_name (argv[0], "10"); 1642 oneone = ! has_in_name (argv[0], "10");
1203 use_non_strict = has_in_name (argv[0], "_nonstrict"); 1643 use_strict_n1 = has_in_name (argv[0], "_strict_n1");
1644 use_strict_zero = has_in_name (argv[0], "_strict_zero");
1645 use_strict_p1 = has_in_name (argv[0], "_strict_p1");
1646 if (1 != ((use_strict_n1 ? 1 : 0) + (use_strict_zero ? 1 : 0)
1647 + (use_strict_p1 ? 1 : 0)))
1648 return 99;
1649
1650 if (use_strict_n1)
1651 strict_level = -1;
1652 else if (use_strict_zero)
1653 strict_level = 0;
1654 else if (use_strict_p1)
1655 strict_level = 1;
1204 1656
1205 test_global_init (); 1657 test_global_init ();
1206 1658