unicorn 5.3.1 → 5.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/.manifest +2 -0
  3. data/.olddoc.yml +1 -1
  4. data/Application_Timeouts +4 -4
  5. data/Documentation/unicorn.1.txt +1 -1
  6. data/Documentation/unicorn_rails.1.txt +6 -8
  7. data/GIT-VERSION-FILE +1 -1
  8. data/GIT-VERSION-GEN +1 -1
  9. data/GNUmakefile +6 -1
  10. data/ISSUES +10 -10
  11. data/LATEST +22 -102
  12. data/LICENSE +2 -2
  13. data/Links +9 -7
  14. data/NEWS +107 -0
  15. data/README +13 -6
  16. data/Sandbox +2 -2
  17. data/bin/unicorn +3 -1
  18. data/bin/unicorn_rails +2 -2
  19. data/examples/logrotate.conf +1 -1
  20. data/examples/nginx.conf +3 -2
  21. data/ext/unicorn_http/common_field_optimization.h +24 -6
  22. data/ext/unicorn_http/extconf.rb +30 -0
  23. data/ext/unicorn_http/global_variables.h +2 -2
  24. data/ext/unicorn_http/httpdate.c +2 -2
  25. data/ext/unicorn_http/unicorn_http.c +229 -219
  26. data/ext/unicorn_http/unicorn_http.rl +19 -9
  27. data/lib/unicorn/configurator.rb +13 -2
  28. data/lib/unicorn/http_request.rb +2 -2
  29. data/lib/unicorn/http_response.rb +3 -2
  30. data/lib/unicorn/http_server.rb +21 -23
  31. data/lib/unicorn/launcher.rb +1 -1
  32. data/lib/unicorn/socket_helper.rb +4 -3
  33. data/lib/unicorn/util.rb +3 -3
  34. data/lib/unicorn/version.rb +1 -1
  35. data/lib/unicorn/worker.rb +16 -2
  36. data/lib/unicorn.rb +26 -9
  37. data/man/man1/unicorn.1 +7 -5
  38. data/man/man1/unicorn_rails.1 +11 -11
  39. data/t/README +4 -4
  40. data/t/hijack.ru +12 -0
  41. data/t/t0200-rack-hijack.sh +22 -1
  42. data/t/t0301-no-default-middleware-ignored-in-config.sh +25 -0
  43. data/t/t0301.ru +13 -0
  44. data/test/exec/test_exec.rb +6 -7
  45. data/test/unit/test_ccc.rb +1 -1
  46. data/test/unit/test_droplet.rb +1 -1
  47. data/test/unit/test_http_parser.rb +16 -0
  48. data/test/unit/test_request.rb +10 -10
  49. data/test/unit/test_server.rb +5 -5
  50. data/test/unit/test_signals.rb +2 -2
  51. data/test/unit/test_socket_helper.rb +4 -4
  52. data/test/unit/test_util.rb +25 -0
  53. data/unicorn.gemspec +1 -1
  54. metadata +5 -4
@@ -15,7 +15,7 @@
15
15
  #include "global_variables.h"
16
16
  #include "c_util.h"
17
17
 
18
- void init_unicorn_httpdate(VALUE mark_ary);
18
+ void init_unicorn_httpdate(void);
19
19
 
20
20
  #define UH_FL_CHUNKED 0x1
21
21
  #define UH_FL_HASBODY 0x2
@@ -28,6 +28,7 @@ void init_unicorn_httpdate(VALUE mark_ary);
28
28
  #define UH_FL_HASHEADER 0x100
29
29
  #define UH_FL_TO_CLEAR 0x200
30
30
  #define UH_FL_RESSTART 0x400 /* for check_client_connection */
31
+ #define UH_FL_HIJACK 0x800
31
32
 
32
33
  /* all of these flags need to be set for keepalive to be supported */
33
34
  #define UH_FL_KEEPALIVE (UH_FL_KAVERSION | UH_FL_REQEOF | UH_FL_HASHEADER)
@@ -286,12 +287,12 @@ static void write_value(struct http_parser *hp,
286
287
  /** Machine **/
287
288
 
288
289
 
289
- #line 393 "unicorn_http.rl"
290
+ #line 394 "unicorn_http.rl"
290
291
 
291
292
 
292
293
  /** Data **/
293
294
 
294
- #line 295 "unicorn_http.c"
295
+ #line 296 "unicorn_http.c"
295
296
  static const int http_parser_start = 1;
296
297
  static const int http_parser_first_final = 122;
297
298
  static const int http_parser_error = 0;
@@ -302,7 +303,7 @@ static const int http_parser_en_Trailers = 114;
302
303
  static const int http_parser_en_main = 1;
303
304
 
304
305
 
305
- #line 397 "unicorn_http.rl"
306
+ #line 398 "unicorn_http.rl"
306
307
 
307
308
  static void http_parser_init(struct http_parser *hp)
308
309
  {
@@ -315,12 +316,12 @@ static void http_parser_init(struct http_parser *hp)
315
316
  hp->len.content = 0;
316
317
  hp->cont = Qfalse; /* zero on MRI, should be optimized away by above */
317
318
 
318
- #line 319 "unicorn_http.c"
319
+ #line 320 "unicorn_http.c"
319
320
  {
320
321
  cs = http_parser_start;
321
322
  }
322
323
 
323
- #line 409 "unicorn_http.rl"
324
+ #line 410 "unicorn_http.rl"
324
325
  hp->cs = cs;
325
326
  }
326
327
 
@@ -348,7 +349,7 @@ http_parser_execute(struct http_parser *hp, char *buffer, size_t len)
348
349
  goto skip_chunk_data_hack;
349
350
  }
350
351
 
351
- #line 352 "unicorn_http.c"
352
+ #line 353 "unicorn_http.c"
352
353
  {
353
354
  if ( p == pe )
354
355
  goto _test_eof;
@@ -383,14 +384,14 @@ st0:
383
384
  cs = 0;
384
385
  goto _out;
385
386
  tr0:
386
- #line 289 "unicorn_http.rl"
387
+ #line 290 "unicorn_http.rl"
387
388
  {MARK(mark, p); }
388
389
  goto st2;
389
390
  st2:
390
391
  if ( ++p == pe )
391
392
  goto _test_eof2;
392
393
  case 2:
393
- #line 394 "unicorn_http.c"
394
+ #line 395 "unicorn_http.c"
394
395
  switch( (*p) ) {
395
396
  case 32: goto tr3;
396
397
  case 33: goto st49;
@@ -416,14 +417,14 @@ case 2:
416
417
  goto st49;
417
418
  goto st0;
418
419
  tr3:
419
- #line 298 "unicorn_http.rl"
420
+ #line 299 "unicorn_http.rl"
420
421
  { request_method(hp, PTR_TO(mark), LEN(mark, p)); }
421
422
  goto st3;
422
423
  st3:
423
424
  if ( ++p == pe )
424
425
  goto _test_eof3;
425
426
  case 3:
426
- #line 427 "unicorn_http.c"
427
+ #line 428 "unicorn_http.c"
427
428
  switch( (*p) ) {
428
429
  case 42: goto tr5;
429
430
  case 47: goto tr6;
@@ -432,21 +433,21 @@ case 3:
432
433
  }
433
434
  goto st0;
434
435
  tr5:
435
- #line 289 "unicorn_http.rl"
436
+ #line 290 "unicorn_http.rl"
436
437
  {MARK(mark, p); }
437
438
  goto st4;
438
439
  st4:
439
440
  if ( ++p == pe )
440
441
  goto _test_eof4;
441
442
  case 4:
442
- #line 443 "unicorn_http.c"
443
+ #line 444 "unicorn_http.c"
443
444
  switch( (*p) ) {
444
445
  case 32: goto tr8;
445
446
  case 35: goto tr9;
446
447
  }
447
448
  goto st0;
448
449
  tr8:
449
- #line 303 "unicorn_http.rl"
450
+ #line 304 "unicorn_http.rl"
450
451
  {
451
452
  VALUE str;
452
453
 
@@ -464,23 +465,23 @@ tr8:
464
465
  }
465
466
  goto st5;
466
467
  tr42:
467
- #line 289 "unicorn_http.rl"
468
+ #line 290 "unicorn_http.rl"
468
469
  {MARK(mark, p); }
469
- #line 318 "unicorn_http.rl"
470
+ #line 319 "unicorn_http.rl"
470
471
  {
471
472
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
472
473
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
473
474
  }
474
475
  goto st5;
475
476
  tr45:
476
- #line 318 "unicorn_http.rl"
477
+ #line 319 "unicorn_http.rl"
477
478
  {
478
479
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
479
480
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
480
481
  }
481
482
  goto st5;
482
483
  tr49:
483
- #line 328 "unicorn_http.rl"
484
+ #line 329 "unicorn_http.rl"
484
485
  {
485
486
  VALUE val;
486
487
 
@@ -491,7 +492,7 @@ tr49:
491
492
  if (!STR_CSTR_EQ(val, "*"))
492
493
  rb_hash_aset(hp->env, g_path_info, val);
493
494
  }
494
- #line 303 "unicorn_http.rl"
495
+ #line 304 "unicorn_http.rl"
495
496
  {
496
497
  VALUE str;
497
498
 
@@ -509,14 +510,14 @@ tr49:
509
510
  }
510
511
  goto st5;
511
512
  tr55:
512
- #line 322 "unicorn_http.rl"
513
- {MARK(start.query, p); }
514
513
  #line 323 "unicorn_http.rl"
514
+ {MARK(start.query, p); }
515
+ #line 324 "unicorn_http.rl"
515
516
  {
516
517
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
517
518
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
518
519
  }
519
- #line 303 "unicorn_http.rl"
520
+ #line 304 "unicorn_http.rl"
520
521
  {
521
522
  VALUE str;
522
523
 
@@ -534,12 +535,12 @@ tr55:
534
535
  }
535
536
  goto st5;
536
537
  tr59:
537
- #line 323 "unicorn_http.rl"
538
+ #line 324 "unicorn_http.rl"
538
539
  {
539
540
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
540
541
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
541
542
  }
542
- #line 303 "unicorn_http.rl"
543
+ #line 304 "unicorn_http.rl"
543
544
  {
544
545
  VALUE str;
545
546
 
@@ -560,19 +561,19 @@ st5:
560
561
  if ( ++p == pe )
561
562
  goto _test_eof5;
562
563
  case 5:
563
- #line 564 "unicorn_http.c"
564
+ #line 565 "unicorn_http.c"
564
565
  if ( (*p) == 72 )
565
566
  goto tr10;
566
567
  goto st0;
567
568
  tr10:
568
- #line 289 "unicorn_http.rl"
569
+ #line 290 "unicorn_http.rl"
569
570
  {MARK(mark, p); }
570
571
  goto st6;
571
572
  st6:
572
573
  if ( ++p == pe )
573
574
  goto _test_eof6;
574
575
  case 6:
575
- #line 576 "unicorn_http.c"
576
+ #line 577 "unicorn_http.c"
576
577
  if ( (*p) == 84 )
577
578
  goto st7;
578
579
  goto st0;
@@ -632,34 +633,34 @@ case 13:
632
633
  goto st13;
633
634
  goto st0;
634
635
  tr18:
635
- #line 327 "unicorn_http.rl"
636
+ #line 328 "unicorn_http.rl"
636
637
  { http_version(hp, PTR_TO(mark), LEN(mark, p)); }
637
638
  goto st14;
638
639
  tr26:
639
- #line 295 "unicorn_http.rl"
640
+ #line 296 "unicorn_http.rl"
640
641
  { MARK(mark, p); }
641
- #line 297 "unicorn_http.rl"
642
+ #line 298 "unicorn_http.rl"
642
643
  { write_cont_value(hp, buffer, p); }
643
644
  goto st14;
644
645
  tr29:
645
- #line 297 "unicorn_http.rl"
646
+ #line 298 "unicorn_http.rl"
646
647
  { write_cont_value(hp, buffer, p); }
647
648
  goto st14;
648
649
  tr36:
649
- #line 295 "unicorn_http.rl"
650
- { MARK(mark, p); }
651
650
  #line 296 "unicorn_http.rl"
651
+ { MARK(mark, p); }
652
+ #line 297 "unicorn_http.rl"
652
653
  { write_value(hp, buffer, p); }
653
654
  goto st14;
654
655
  tr39:
655
- #line 296 "unicorn_http.rl"
656
+ #line 297 "unicorn_http.rl"
656
657
  { write_value(hp, buffer, p); }
657
658
  goto st14;
658
659
  st14:
659
660
  if ( ++p == pe )
660
661
  goto _test_eof14;
661
662
  case 14:
662
- #line 663 "unicorn_http.c"
663
+ #line 664 "unicorn_http.c"
663
664
  switch( (*p) ) {
664
665
  case 9: goto st15;
665
666
  case 10: goto tr21;
@@ -688,14 +689,14 @@ case 14:
688
689
  goto tr23;
689
690
  goto st0;
690
691
  tr25:
691
- #line 295 "unicorn_http.rl"
692
+ #line 296 "unicorn_http.rl"
692
693
  { MARK(mark, p); }
693
694
  goto st15;
694
695
  st15:
695
696
  if ( ++p == pe )
696
697
  goto _test_eof15;
697
698
  case 15:
698
- #line 699 "unicorn_http.c"
699
+ #line 700 "unicorn_http.c"
699
700
  switch( (*p) ) {
700
701
  case 9: goto tr25;
701
702
  case 10: goto tr26;
@@ -707,14 +708,14 @@ case 15:
707
708
  goto st0;
708
709
  goto tr24;
709
710
  tr24:
710
- #line 295 "unicorn_http.rl"
711
+ #line 296 "unicorn_http.rl"
711
712
  { MARK(mark, p); }
712
713
  goto st16;
713
714
  st16:
714
715
  if ( ++p == pe )
715
716
  goto _test_eof16;
716
717
  case 16:
717
- #line 718 "unicorn_http.c"
718
+ #line 719 "unicorn_http.c"
718
719
  switch( (*p) ) {
719
720
  case 10: goto tr29;
720
721
  case 13: goto tr30;
@@ -727,39 +728,39 @@ case 16:
727
728
  goto st0;
728
729
  goto st16;
729
730
  tr19:
730
- #line 327 "unicorn_http.rl"
731
+ #line 328 "unicorn_http.rl"
731
732
  { http_version(hp, PTR_TO(mark), LEN(mark, p)); }
732
733
  goto st17;
733
734
  tr27:
734
- #line 295 "unicorn_http.rl"
735
+ #line 296 "unicorn_http.rl"
735
736
  { MARK(mark, p); }
736
- #line 297 "unicorn_http.rl"
737
+ #line 298 "unicorn_http.rl"
737
738
  { write_cont_value(hp, buffer, p); }
738
739
  goto st17;
739
740
  tr30:
740
- #line 297 "unicorn_http.rl"
741
+ #line 298 "unicorn_http.rl"
741
742
  { write_cont_value(hp, buffer, p); }
742
743
  goto st17;
743
744
  tr37:
744
- #line 295 "unicorn_http.rl"
745
- { MARK(mark, p); }
746
745
  #line 296 "unicorn_http.rl"
746
+ { MARK(mark, p); }
747
+ #line 297 "unicorn_http.rl"
747
748
  { write_value(hp, buffer, p); }
748
749
  goto st17;
749
750
  tr40:
750
- #line 296 "unicorn_http.rl"
751
+ #line 297 "unicorn_http.rl"
751
752
  { write_value(hp, buffer, p); }
752
753
  goto st17;
753
754
  st17:
754
755
  if ( ++p == pe )
755
756
  goto _test_eof17;
756
757
  case 17:
757
- #line 758 "unicorn_http.c"
758
+ #line 759 "unicorn_http.c"
758
759
  if ( (*p) == 10 )
759
760
  goto st14;
760
761
  goto st0;
761
762
  tr21:
762
- #line 343 "unicorn_http.rl"
763
+ #line 344 "unicorn_http.rl"
763
764
  {
764
765
  finalize_header(hp);
765
766
 
@@ -780,7 +781,7 @@ tr21:
780
781
  }
781
782
  goto st122;
782
783
  tr104:
783
- #line 303 "unicorn_http.rl"
784
+ #line 304 "unicorn_http.rl"
784
785
  {
785
786
  VALUE str;
786
787
 
@@ -796,7 +797,7 @@ tr104:
796
797
  rb_hash_aset(hp->env, g_request_path, str);
797
798
  }
798
799
  }
799
- #line 343 "unicorn_http.rl"
800
+ #line 344 "unicorn_http.rl"
800
801
  {
801
802
  finalize_header(hp);
802
803
 
@@ -817,14 +818,14 @@ tr104:
817
818
  }
818
819
  goto st122;
819
820
  tr108:
820
- #line 289 "unicorn_http.rl"
821
+ #line 290 "unicorn_http.rl"
821
822
  {MARK(mark, p); }
822
- #line 318 "unicorn_http.rl"
823
+ #line 319 "unicorn_http.rl"
823
824
  {
824
825
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
825
826
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
826
827
  }
827
- #line 343 "unicorn_http.rl"
828
+ #line 344 "unicorn_http.rl"
828
829
  {
829
830
  finalize_header(hp);
830
831
 
@@ -845,12 +846,12 @@ tr108:
845
846
  }
846
847
  goto st122;
847
848
  tr112:
848
- #line 318 "unicorn_http.rl"
849
+ #line 319 "unicorn_http.rl"
849
850
  {
850
851
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
851
852
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
852
853
  }
853
- #line 343 "unicorn_http.rl"
854
+ #line 344 "unicorn_http.rl"
854
855
  {
855
856
  finalize_header(hp);
856
857
 
@@ -871,7 +872,7 @@ tr112:
871
872
  }
872
873
  goto st122;
873
874
  tr117:
874
- #line 328 "unicorn_http.rl"
875
+ #line 329 "unicorn_http.rl"
875
876
  {
876
877
  VALUE val;
877
878
 
@@ -882,7 +883,7 @@ tr117:
882
883
  if (!STR_CSTR_EQ(val, "*"))
883
884
  rb_hash_aset(hp->env, g_path_info, val);
884
885
  }
885
- #line 303 "unicorn_http.rl"
886
+ #line 304 "unicorn_http.rl"
886
887
  {
887
888
  VALUE str;
888
889
 
@@ -898,7 +899,7 @@ tr117:
898
899
  rb_hash_aset(hp->env, g_request_path, str);
899
900
  }
900
901
  }
901
- #line 343 "unicorn_http.rl"
902
+ #line 344 "unicorn_http.rl"
902
903
  {
903
904
  finalize_header(hp);
904
905
 
@@ -919,14 +920,14 @@ tr117:
919
920
  }
920
921
  goto st122;
921
922
  tr124:
922
- #line 322 "unicorn_http.rl"
923
- {MARK(start.query, p); }
924
923
  #line 323 "unicorn_http.rl"
924
+ {MARK(start.query, p); }
925
+ #line 324 "unicorn_http.rl"
925
926
  {
926
927
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
927
928
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
928
929
  }
929
- #line 303 "unicorn_http.rl"
930
+ #line 304 "unicorn_http.rl"
930
931
  {
931
932
  VALUE str;
932
933
 
@@ -942,7 +943,7 @@ tr124:
942
943
  rb_hash_aset(hp->env, g_request_path, str);
943
944
  }
944
945
  }
945
- #line 343 "unicorn_http.rl"
946
+ #line 344 "unicorn_http.rl"
946
947
  {
947
948
  finalize_header(hp);
948
949
 
@@ -963,12 +964,12 @@ tr124:
963
964
  }
964
965
  goto st122;
965
966
  tr129:
966
- #line 323 "unicorn_http.rl"
967
+ #line 324 "unicorn_http.rl"
967
968
  {
968
969
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
969
970
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
970
971
  }
971
- #line 303 "unicorn_http.rl"
972
+ #line 304 "unicorn_http.rl"
972
973
  {
973
974
  VALUE str;
974
975
 
@@ -984,7 +985,7 @@ tr129:
984
985
  rb_hash_aset(hp->env, g_request_path, str);
985
986
  }
986
987
  }
987
- #line 343 "unicorn_http.rl"
988
+ #line 344 "unicorn_http.rl"
988
989
  {
989
990
  finalize_header(hp);
990
991
 
@@ -1008,10 +1009,10 @@ st122:
1008
1009
  if ( ++p == pe )
1009
1010
  goto _test_eof122;
1010
1011
  case 122:
1011
- #line 1012 "unicorn_http.c"
1012
+ #line 1013 "unicorn_http.c"
1012
1013
  goto st0;
1013
1014
  tr105:
1014
- #line 303 "unicorn_http.rl"
1015
+ #line 304 "unicorn_http.rl"
1015
1016
  {
1016
1017
  VALUE str;
1017
1018
 
@@ -1029,23 +1030,23 @@ tr105:
1029
1030
  }
1030
1031
  goto st18;
1031
1032
  tr109:
1032
- #line 289 "unicorn_http.rl"
1033
+ #line 290 "unicorn_http.rl"
1033
1034
  {MARK(mark, p); }
1034
- #line 318 "unicorn_http.rl"
1035
+ #line 319 "unicorn_http.rl"
1035
1036
  {
1036
1037
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
1037
1038
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
1038
1039
  }
1039
1040
  goto st18;
1040
1041
  tr113:
1041
- #line 318 "unicorn_http.rl"
1042
+ #line 319 "unicorn_http.rl"
1042
1043
  {
1043
1044
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
1044
1045
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
1045
1046
  }
1046
1047
  goto st18;
1047
1048
  tr118:
1048
- #line 328 "unicorn_http.rl"
1049
+ #line 329 "unicorn_http.rl"
1049
1050
  {
1050
1051
  VALUE val;
1051
1052
 
@@ -1056,7 +1057,7 @@ tr118:
1056
1057
  if (!STR_CSTR_EQ(val, "*"))
1057
1058
  rb_hash_aset(hp->env, g_path_info, val);
1058
1059
  }
1059
- #line 303 "unicorn_http.rl"
1060
+ #line 304 "unicorn_http.rl"
1060
1061
  {
1061
1062
  VALUE str;
1062
1063
 
@@ -1074,14 +1075,14 @@ tr118:
1074
1075
  }
1075
1076
  goto st18;
1076
1077
  tr125:
1077
- #line 322 "unicorn_http.rl"
1078
- {MARK(start.query, p); }
1079
1078
  #line 323 "unicorn_http.rl"
1079
+ {MARK(start.query, p); }
1080
+ #line 324 "unicorn_http.rl"
1080
1081
  {
1081
1082
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1082
1083
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1083
1084
  }
1084
- #line 303 "unicorn_http.rl"
1085
+ #line 304 "unicorn_http.rl"
1085
1086
  {
1086
1087
  VALUE str;
1087
1088
 
@@ -1099,12 +1100,12 @@ tr125:
1099
1100
  }
1100
1101
  goto st18;
1101
1102
  tr130:
1102
- #line 323 "unicorn_http.rl"
1103
+ #line 324 "unicorn_http.rl"
1103
1104
  {
1104
1105
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1105
1106
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1106
1107
  }
1107
- #line 303 "unicorn_http.rl"
1108
+ #line 304 "unicorn_http.rl"
1108
1109
  {
1109
1110
  VALUE str;
1110
1111
 
@@ -1125,25 +1126,25 @@ st18:
1125
1126
  if ( ++p == pe )
1126
1127
  goto _test_eof18;
1127
1128
  case 18:
1128
- #line 1129 "unicorn_http.c"
1129
+ #line 1130 "unicorn_http.c"
1129
1130
  if ( (*p) == 10 )
1130
1131
  goto tr21;
1131
1132
  goto st0;
1132
1133
  tr23:
1133
- #line 291 "unicorn_http.rl"
1134
- { MARK(start.field, p); }
1135
1134
  #line 292 "unicorn_http.rl"
1135
+ { MARK(start.field, p); }
1136
+ #line 293 "unicorn_http.rl"
1136
1137
  { snake_upcase_char(deconst(p)); }
1137
1138
  goto st19;
1138
1139
  tr32:
1139
- #line 292 "unicorn_http.rl"
1140
+ #line 293 "unicorn_http.rl"
1140
1141
  { snake_upcase_char(deconst(p)); }
1141
1142
  goto st19;
1142
1143
  st19:
1143
1144
  if ( ++p == pe )
1144
1145
  goto _test_eof19;
1145
1146
  case 19:
1146
- #line 1147 "unicorn_http.c"
1147
+ #line 1148 "unicorn_http.c"
1147
1148
  switch( (*p) ) {
1148
1149
  case 33: goto tr32;
1149
1150
  case 58: goto tr33;
@@ -1169,18 +1170,18 @@ case 19:
1169
1170
  goto tr32;
1170
1171
  goto st0;
1171
1172
  tr35:
1172
- #line 295 "unicorn_http.rl"
1173
+ #line 296 "unicorn_http.rl"
1173
1174
  { MARK(mark, p); }
1174
1175
  goto st20;
1175
1176
  tr33:
1176
- #line 294 "unicorn_http.rl"
1177
+ #line 295 "unicorn_http.rl"
1177
1178
  { hp->s.field_len = LEN(start.field, p); }
1178
1179
  goto st20;
1179
1180
  st20:
1180
1181
  if ( ++p == pe )
1181
1182
  goto _test_eof20;
1182
1183
  case 20:
1183
- #line 1184 "unicorn_http.c"
1184
+ #line 1185 "unicorn_http.c"
1184
1185
  switch( (*p) ) {
1185
1186
  case 9: goto tr35;
1186
1187
  case 10: goto tr36;
@@ -1192,14 +1193,14 @@ case 20:
1192
1193
  goto st0;
1193
1194
  goto tr34;
1194
1195
  tr34:
1195
- #line 295 "unicorn_http.rl"
1196
+ #line 296 "unicorn_http.rl"
1196
1197
  { MARK(mark, p); }
1197
1198
  goto st21;
1198
1199
  st21:
1199
1200
  if ( ++p == pe )
1200
1201
  goto _test_eof21;
1201
1202
  case 21:
1202
- #line 1203 "unicorn_http.c"
1203
+ #line 1204 "unicorn_http.c"
1203
1204
  switch( (*p) ) {
1204
1205
  case 10: goto tr39;
1205
1206
  case 13: goto tr40;
@@ -1212,7 +1213,7 @@ case 21:
1212
1213
  goto st0;
1213
1214
  goto st21;
1214
1215
  tr9:
1215
- #line 303 "unicorn_http.rl"
1216
+ #line 304 "unicorn_http.rl"
1216
1217
  {
1217
1218
  VALUE str;
1218
1219
 
@@ -1230,7 +1231,7 @@ tr9:
1230
1231
  }
1231
1232
  goto st22;
1232
1233
  tr50:
1233
- #line 328 "unicorn_http.rl"
1234
+ #line 329 "unicorn_http.rl"
1234
1235
  {
1235
1236
  VALUE val;
1236
1237
 
@@ -1241,7 +1242,7 @@ tr50:
1241
1242
  if (!STR_CSTR_EQ(val, "*"))
1242
1243
  rb_hash_aset(hp->env, g_path_info, val);
1243
1244
  }
1244
- #line 303 "unicorn_http.rl"
1245
+ #line 304 "unicorn_http.rl"
1245
1246
  {
1246
1247
  VALUE str;
1247
1248
 
@@ -1259,14 +1260,14 @@ tr50:
1259
1260
  }
1260
1261
  goto st22;
1261
1262
  tr56:
1262
- #line 322 "unicorn_http.rl"
1263
- {MARK(start.query, p); }
1264
1263
  #line 323 "unicorn_http.rl"
1264
+ {MARK(start.query, p); }
1265
+ #line 324 "unicorn_http.rl"
1265
1266
  {
1266
1267
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1267
1268
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1268
1269
  }
1269
- #line 303 "unicorn_http.rl"
1270
+ #line 304 "unicorn_http.rl"
1270
1271
  {
1271
1272
  VALUE str;
1272
1273
 
@@ -1284,12 +1285,12 @@ tr56:
1284
1285
  }
1285
1286
  goto st22;
1286
1287
  tr60:
1287
- #line 323 "unicorn_http.rl"
1288
+ #line 324 "unicorn_http.rl"
1288
1289
  {
1289
1290
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1290
1291
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1291
1292
  }
1292
- #line 303 "unicorn_http.rl"
1293
+ #line 304 "unicorn_http.rl"
1293
1294
  {
1294
1295
  VALUE str;
1295
1296
 
@@ -1310,7 +1311,7 @@ st22:
1310
1311
  if ( ++p == pe )
1311
1312
  goto _test_eof22;
1312
1313
  case 22:
1313
- #line 1314 "unicorn_http.c"
1314
+ #line 1315 "unicorn_http.c"
1314
1315
  switch( (*p) ) {
1315
1316
  case 32: goto tr42;
1316
1317
  case 35: goto st0;
@@ -1321,14 +1322,14 @@ case 22:
1321
1322
  goto st0;
1322
1323
  goto tr41;
1323
1324
  tr41:
1324
- #line 289 "unicorn_http.rl"
1325
+ #line 290 "unicorn_http.rl"
1325
1326
  {MARK(mark, p); }
1326
1327
  goto st23;
1327
1328
  st23:
1328
1329
  if ( ++p == pe )
1329
1330
  goto _test_eof23;
1330
1331
  case 23:
1331
- #line 1332 "unicorn_http.c"
1332
+ #line 1333 "unicorn_http.c"
1332
1333
  switch( (*p) ) {
1333
1334
  case 32: goto tr45;
1334
1335
  case 35: goto st0;
@@ -1339,14 +1340,14 @@ case 23:
1339
1340
  goto st0;
1340
1341
  goto st23;
1341
1342
  tr43:
1342
- #line 289 "unicorn_http.rl"
1343
+ #line 290 "unicorn_http.rl"
1343
1344
  {MARK(mark, p); }
1344
1345
  goto st24;
1345
1346
  st24:
1346
1347
  if ( ++p == pe )
1347
1348
  goto _test_eof24;
1348
1349
  case 24:
1349
- #line 1350 "unicorn_http.c"
1350
+ #line 1351 "unicorn_http.c"
1350
1351
  if ( (*p) < 65 ) {
1351
1352
  if ( 48 <= (*p) && (*p) <= 57 )
1352
1353
  goto st25;
@@ -1370,20 +1371,20 @@ case 25:
1370
1371
  goto st23;
1371
1372
  goto st0;
1372
1373
  tr6:
1373
- #line 289 "unicorn_http.rl"
1374
+ #line 290 "unicorn_http.rl"
1374
1375
  {MARK(mark, p); }
1375
1376
  goto st26;
1376
1377
  tr76:
1377
- #line 302 "unicorn_http.rl"
1378
+ #line 303 "unicorn_http.rl"
1378
1379
  { rb_hash_aset(hp->env, g_http_host, STR_NEW(mark, p)); }
1379
- #line 289 "unicorn_http.rl"
1380
+ #line 290 "unicorn_http.rl"
1380
1381
  {MARK(mark, p); }
1381
1382
  goto st26;
1382
1383
  st26:
1383
1384
  if ( ++p == pe )
1384
1385
  goto _test_eof26;
1385
1386
  case 26:
1386
- #line 1387 "unicorn_http.c"
1387
+ #line 1388 "unicorn_http.c"
1387
1388
  switch( (*p) ) {
1388
1389
  case 32: goto tr49;
1389
1390
  case 35: goto tr50;
@@ -1421,7 +1422,7 @@ case 28:
1421
1422
  goto st26;
1422
1423
  goto st0;
1423
1424
  tr52:
1424
- #line 328 "unicorn_http.rl"
1425
+ #line 329 "unicorn_http.rl"
1425
1426
  {
1426
1427
  VALUE val;
1427
1428
 
@@ -1437,7 +1438,7 @@ st29:
1437
1438
  if ( ++p == pe )
1438
1439
  goto _test_eof29;
1439
1440
  case 29:
1440
- #line 1441 "unicorn_http.c"
1441
+ #line 1442 "unicorn_http.c"
1441
1442
  switch( (*p) ) {
1442
1443
  case 32: goto tr55;
1443
1444
  case 35: goto tr56;
@@ -1448,14 +1449,14 @@ case 29:
1448
1449
  goto st0;
1449
1450
  goto tr54;
1450
1451
  tr54:
1451
- #line 322 "unicorn_http.rl"
1452
+ #line 323 "unicorn_http.rl"
1452
1453
  {MARK(start.query, p); }
1453
1454
  goto st30;
1454
1455
  st30:
1455
1456
  if ( ++p == pe )
1456
1457
  goto _test_eof30;
1457
1458
  case 30:
1458
- #line 1459 "unicorn_http.c"
1459
+ #line 1460 "unicorn_http.c"
1459
1460
  switch( (*p) ) {
1460
1461
  case 32: goto tr59;
1461
1462
  case 35: goto tr60;
@@ -1466,14 +1467,14 @@ case 30:
1466
1467
  goto st0;
1467
1468
  goto st30;
1468
1469
  tr57:
1469
- #line 322 "unicorn_http.rl"
1470
+ #line 323 "unicorn_http.rl"
1470
1471
  {MARK(start.query, p); }
1471
1472
  goto st31;
1472
1473
  st31:
1473
1474
  if ( ++p == pe )
1474
1475
  goto _test_eof31;
1475
1476
  case 31:
1476
- #line 1477 "unicorn_http.c"
1477
+ #line 1478 "unicorn_http.c"
1477
1478
  if ( (*p) < 65 ) {
1478
1479
  if ( 48 <= (*p) && (*p) <= 57 )
1479
1480
  goto st32;
@@ -1497,58 +1498,58 @@ case 32:
1497
1498
  goto st30;
1498
1499
  goto st0;
1499
1500
  tr7:
1500
- #line 289 "unicorn_http.rl"
1501
+ #line 290 "unicorn_http.rl"
1501
1502
  {MARK(mark, p); }
1502
- #line 293 "unicorn_http.rl"
1503
+ #line 294 "unicorn_http.rl"
1503
1504
  { downcase_char(deconst(p)); }
1504
1505
  goto st33;
1505
1506
  st33:
1506
1507
  if ( ++p == pe )
1507
1508
  goto _test_eof33;
1508
1509
  case 33:
1509
- #line 1510 "unicorn_http.c"
1510
+ #line 1511 "unicorn_http.c"
1510
1511
  switch( (*p) ) {
1511
1512
  case 84: goto tr63;
1512
1513
  case 116: goto tr63;
1513
1514
  }
1514
1515
  goto st0;
1515
1516
  tr63:
1516
- #line 293 "unicorn_http.rl"
1517
+ #line 294 "unicorn_http.rl"
1517
1518
  { downcase_char(deconst(p)); }
1518
1519
  goto st34;
1519
1520
  st34:
1520
1521
  if ( ++p == pe )
1521
1522
  goto _test_eof34;
1522
1523
  case 34:
1523
- #line 1524 "unicorn_http.c"
1524
+ #line 1525 "unicorn_http.c"
1524
1525
  switch( (*p) ) {
1525
1526
  case 84: goto tr64;
1526
1527
  case 116: goto tr64;
1527
1528
  }
1528
1529
  goto st0;
1529
1530
  tr64:
1530
- #line 293 "unicorn_http.rl"
1531
+ #line 294 "unicorn_http.rl"
1531
1532
  { downcase_char(deconst(p)); }
1532
1533
  goto st35;
1533
1534
  st35:
1534
1535
  if ( ++p == pe )
1535
1536
  goto _test_eof35;
1536
1537
  case 35:
1537
- #line 1538 "unicorn_http.c"
1538
+ #line 1539 "unicorn_http.c"
1538
1539
  switch( (*p) ) {
1539
1540
  case 80: goto tr65;
1540
1541
  case 112: goto tr65;
1541
1542
  }
1542
1543
  goto st0;
1543
1544
  tr65:
1544
- #line 293 "unicorn_http.rl"
1545
+ #line 294 "unicorn_http.rl"
1545
1546
  { downcase_char(deconst(p)); }
1546
1547
  goto st36;
1547
1548
  st36:
1548
1549
  if ( ++p == pe )
1549
1550
  goto _test_eof36;
1550
1551
  case 36:
1551
- #line 1552 "unicorn_http.c"
1552
+ #line 1553 "unicorn_http.c"
1552
1553
  switch( (*p) ) {
1553
1554
  case 58: goto tr66;
1554
1555
  case 83: goto tr67;
@@ -1556,7 +1557,7 @@ case 36:
1556
1557
  }
1557
1558
  goto st0;
1558
1559
  tr66:
1559
- #line 299 "unicorn_http.rl"
1560
+ #line 300 "unicorn_http.rl"
1560
1561
  {
1561
1562
  rb_hash_aset(hp->env, g_rack_url_scheme, STR_NEW(mark, p));
1562
1563
  }
@@ -1565,7 +1566,7 @@ st37:
1565
1566
  if ( ++p == pe )
1566
1567
  goto _test_eof37;
1567
1568
  case 37:
1568
- #line 1569 "unicorn_http.c"
1569
+ #line 1570 "unicorn_http.c"
1569
1570
  if ( (*p) == 47 )
1570
1571
  goto st38;
1571
1572
  goto st0;
@@ -1653,14 +1654,14 @@ case 42:
1653
1654
  goto st40;
1654
1655
  goto st0;
1655
1656
  tr72:
1656
- #line 289 "unicorn_http.rl"
1657
+ #line 290 "unicorn_http.rl"
1657
1658
  {MARK(mark, p); }
1658
1659
  goto st43;
1659
1660
  st43:
1660
1661
  if ( ++p == pe )
1661
1662
  goto _test_eof43;
1662
1663
  case 43:
1663
- #line 1664 "unicorn_http.c"
1664
+ #line 1665 "unicorn_http.c"
1664
1665
  switch( (*p) ) {
1665
1666
  case 37: goto st41;
1666
1667
  case 47: goto tr76;
@@ -1712,14 +1713,14 @@ case 44:
1712
1713
  goto st0;
1713
1714
  goto st40;
1714
1715
  tr73:
1715
- #line 289 "unicorn_http.rl"
1716
+ #line 290 "unicorn_http.rl"
1716
1717
  {MARK(mark, p); }
1717
1718
  goto st45;
1718
1719
  st45:
1719
1720
  if ( ++p == pe )
1720
1721
  goto _test_eof45;
1721
1722
  case 45:
1722
- #line 1723 "unicorn_http.c"
1723
+ #line 1724 "unicorn_http.c"
1723
1724
  switch( (*p) ) {
1724
1725
  case 37: goto st41;
1725
1726
  case 47: goto st0;
@@ -1797,14 +1798,14 @@ case 47:
1797
1798
  goto st0;
1798
1799
  goto st40;
1799
1800
  tr67:
1800
- #line 293 "unicorn_http.rl"
1801
+ #line 294 "unicorn_http.rl"
1801
1802
  { downcase_char(deconst(p)); }
1802
1803
  goto st48;
1803
1804
  st48:
1804
1805
  if ( ++p == pe )
1805
1806
  goto _test_eof48;
1806
1807
  case 48:
1807
- #line 1808 "unicorn_http.c"
1808
+ #line 1809 "unicorn_http.c"
1808
1809
  if ( (*p) == 58 )
1809
1810
  goto tr66;
1810
1811
  goto st0;
@@ -2320,14 +2321,14 @@ case 67:
2320
2321
  goto tr3;
2321
2322
  goto st0;
2322
2323
  tr2:
2323
- #line 289 "unicorn_http.rl"
2324
+ #line 290 "unicorn_http.rl"
2324
2325
  {MARK(mark, p); }
2325
2326
  goto st68;
2326
2327
  st68:
2327
2328
  if ( ++p == pe )
2328
2329
  goto _test_eof68;
2329
2330
  case 68:
2330
- #line 2331 "unicorn_http.c"
2331
+ #line 2332 "unicorn_http.c"
2331
2332
  switch( (*p) ) {
2332
2333
  case 32: goto tr3;
2333
2334
  case 33: goto st49;
@@ -2411,14 +2412,14 @@ case 70:
2411
2412
  goto st51;
2412
2413
  goto st0;
2413
2414
  tr100:
2414
- #line 298 "unicorn_http.rl"
2415
+ #line 299 "unicorn_http.rl"
2415
2416
  { request_method(hp, PTR_TO(mark), LEN(mark, p)); }
2416
2417
  goto st71;
2417
2418
  st71:
2418
2419
  if ( ++p == pe )
2419
2420
  goto _test_eof71;
2420
2421
  case 71:
2421
- #line 2422 "unicorn_http.c"
2422
+ #line 2423 "unicorn_http.c"
2422
2423
  switch( (*p) ) {
2423
2424
  case 42: goto tr101;
2424
2425
  case 47: goto tr102;
@@ -2427,14 +2428,14 @@ case 71:
2427
2428
  }
2428
2429
  goto st0;
2429
2430
  tr101:
2430
- #line 289 "unicorn_http.rl"
2431
+ #line 290 "unicorn_http.rl"
2431
2432
  {MARK(mark, p); }
2432
2433
  goto st72;
2433
2434
  st72:
2434
2435
  if ( ++p == pe )
2435
2436
  goto _test_eof72;
2436
2437
  case 72:
2437
- #line 2438 "unicorn_http.c"
2438
+ #line 2439 "unicorn_http.c"
2438
2439
  switch( (*p) ) {
2439
2440
  case 10: goto tr104;
2440
2441
  case 13: goto tr105;
@@ -2443,7 +2444,7 @@ case 72:
2443
2444
  }
2444
2445
  goto st0;
2445
2446
  tr106:
2446
- #line 303 "unicorn_http.rl"
2447
+ #line 304 "unicorn_http.rl"
2447
2448
  {
2448
2449
  VALUE str;
2449
2450
 
@@ -2461,7 +2462,7 @@ tr106:
2461
2462
  }
2462
2463
  goto st73;
2463
2464
  tr119:
2464
- #line 328 "unicorn_http.rl"
2465
+ #line 329 "unicorn_http.rl"
2465
2466
  {
2466
2467
  VALUE val;
2467
2468
 
@@ -2472,7 +2473,7 @@ tr119:
2472
2473
  if (!STR_CSTR_EQ(val, "*"))
2473
2474
  rb_hash_aset(hp->env, g_path_info, val);
2474
2475
  }
2475
- #line 303 "unicorn_http.rl"
2476
+ #line 304 "unicorn_http.rl"
2476
2477
  {
2477
2478
  VALUE str;
2478
2479
 
@@ -2490,14 +2491,14 @@ tr119:
2490
2491
  }
2491
2492
  goto st73;
2492
2493
  tr126:
2493
- #line 322 "unicorn_http.rl"
2494
- {MARK(start.query, p); }
2495
2494
  #line 323 "unicorn_http.rl"
2495
+ {MARK(start.query, p); }
2496
+ #line 324 "unicorn_http.rl"
2496
2497
  {
2497
2498
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
2498
2499
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
2499
2500
  }
2500
- #line 303 "unicorn_http.rl"
2501
+ #line 304 "unicorn_http.rl"
2501
2502
  {
2502
2503
  VALUE str;
2503
2504
 
@@ -2515,12 +2516,12 @@ tr126:
2515
2516
  }
2516
2517
  goto st73;
2517
2518
  tr131:
2518
- #line 323 "unicorn_http.rl"
2519
+ #line 324 "unicorn_http.rl"
2519
2520
  {
2520
2521
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
2521
2522
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
2522
2523
  }
2523
- #line 303 "unicorn_http.rl"
2524
+ #line 304 "unicorn_http.rl"
2524
2525
  {
2525
2526
  VALUE str;
2526
2527
 
@@ -2541,7 +2542,7 @@ st73:
2541
2542
  if ( ++p == pe )
2542
2543
  goto _test_eof73;
2543
2544
  case 73:
2544
- #line 2545 "unicorn_http.c"
2545
+ #line 2546 "unicorn_http.c"
2545
2546
  switch( (*p) ) {
2546
2547
  case 10: goto tr108;
2547
2548
  case 13: goto tr109;
@@ -2554,14 +2555,14 @@ case 73:
2554
2555
  goto st0;
2555
2556
  goto tr107;
2556
2557
  tr107:
2557
- #line 289 "unicorn_http.rl"
2558
+ #line 290 "unicorn_http.rl"
2558
2559
  {MARK(mark, p); }
2559
2560
  goto st74;
2560
2561
  st74:
2561
2562
  if ( ++p == pe )
2562
2563
  goto _test_eof74;
2563
2564
  case 74:
2564
- #line 2565 "unicorn_http.c"
2565
+ #line 2566 "unicorn_http.c"
2565
2566
  switch( (*p) ) {
2566
2567
  case 10: goto tr112;
2567
2568
  case 13: goto tr113;
@@ -2574,14 +2575,14 @@ case 74:
2574
2575
  goto st0;
2575
2576
  goto st74;
2576
2577
  tr110:
2577
- #line 289 "unicorn_http.rl"
2578
+ #line 290 "unicorn_http.rl"
2578
2579
  {MARK(mark, p); }
2579
2580
  goto st75;
2580
2581
  st75:
2581
2582
  if ( ++p == pe )
2582
2583
  goto _test_eof75;
2583
2584
  case 75:
2584
- #line 2585 "unicorn_http.c"
2585
+ #line 2586 "unicorn_http.c"
2585
2586
  if ( (*p) < 65 ) {
2586
2587
  if ( 48 <= (*p) && (*p) <= 57 )
2587
2588
  goto st76;
@@ -2605,20 +2606,20 @@ case 76:
2605
2606
  goto st74;
2606
2607
  goto st0;
2607
2608
  tr102:
2608
- #line 289 "unicorn_http.rl"
2609
+ #line 290 "unicorn_http.rl"
2609
2610
  {MARK(mark, p); }
2610
2611
  goto st77;
2611
2612
  tr147:
2612
- #line 302 "unicorn_http.rl"
2613
+ #line 303 "unicorn_http.rl"
2613
2614
  { rb_hash_aset(hp->env, g_http_host, STR_NEW(mark, p)); }
2614
- #line 289 "unicorn_http.rl"
2615
+ #line 290 "unicorn_http.rl"
2615
2616
  {MARK(mark, p); }
2616
2617
  goto st77;
2617
2618
  st77:
2618
2619
  if ( ++p == pe )
2619
2620
  goto _test_eof77;
2620
2621
  case 77:
2621
- #line 2622 "unicorn_http.c"
2622
+ #line 2623 "unicorn_http.c"
2622
2623
  switch( (*p) ) {
2623
2624
  case 10: goto tr117;
2624
2625
  case 13: goto tr118;
@@ -2658,7 +2659,7 @@ case 79:
2658
2659
  goto st77;
2659
2660
  goto st0;
2660
2661
  tr121:
2661
- #line 328 "unicorn_http.rl"
2662
+ #line 329 "unicorn_http.rl"
2662
2663
  {
2663
2664
  VALUE val;
2664
2665
 
@@ -2674,7 +2675,7 @@ st80:
2674
2675
  if ( ++p == pe )
2675
2676
  goto _test_eof80;
2676
2677
  case 80:
2677
- #line 2678 "unicorn_http.c"
2678
+ #line 2679 "unicorn_http.c"
2678
2679
  switch( (*p) ) {
2679
2680
  case 10: goto tr124;
2680
2681
  case 13: goto tr125;
@@ -2687,14 +2688,14 @@ case 80:
2687
2688
  goto st0;
2688
2689
  goto tr123;
2689
2690
  tr123:
2690
- #line 322 "unicorn_http.rl"
2691
+ #line 323 "unicorn_http.rl"
2691
2692
  {MARK(start.query, p); }
2692
2693
  goto st81;
2693
2694
  st81:
2694
2695
  if ( ++p == pe )
2695
2696
  goto _test_eof81;
2696
2697
  case 81:
2697
- #line 2698 "unicorn_http.c"
2698
+ #line 2699 "unicorn_http.c"
2698
2699
  switch( (*p) ) {
2699
2700
  case 10: goto tr129;
2700
2701
  case 13: goto tr130;
@@ -2707,14 +2708,14 @@ case 81:
2707
2708
  goto st0;
2708
2709
  goto st81;
2709
2710
  tr127:
2710
- #line 322 "unicorn_http.rl"
2711
+ #line 323 "unicorn_http.rl"
2711
2712
  {MARK(start.query, p); }
2712
2713
  goto st82;
2713
2714
  st82:
2714
2715
  if ( ++p == pe )
2715
2716
  goto _test_eof82;
2716
2717
  case 82:
2717
- #line 2718 "unicorn_http.c"
2718
+ #line 2719 "unicorn_http.c"
2718
2719
  if ( (*p) < 65 ) {
2719
2720
  if ( 48 <= (*p) && (*p) <= 57 )
2720
2721
  goto st83;
@@ -2738,58 +2739,58 @@ case 83:
2738
2739
  goto st81;
2739
2740
  goto st0;
2740
2741
  tr103:
2741
- #line 289 "unicorn_http.rl"
2742
+ #line 290 "unicorn_http.rl"
2742
2743
  {MARK(mark, p); }
2743
- #line 293 "unicorn_http.rl"
2744
+ #line 294 "unicorn_http.rl"
2744
2745
  { downcase_char(deconst(p)); }
2745
2746
  goto st84;
2746
2747
  st84:
2747
2748
  if ( ++p == pe )
2748
2749
  goto _test_eof84;
2749
2750
  case 84:
2750
- #line 2751 "unicorn_http.c"
2751
+ #line 2752 "unicorn_http.c"
2751
2752
  switch( (*p) ) {
2752
2753
  case 84: goto tr134;
2753
2754
  case 116: goto tr134;
2754
2755
  }
2755
2756
  goto st0;
2756
2757
  tr134:
2757
- #line 293 "unicorn_http.rl"
2758
+ #line 294 "unicorn_http.rl"
2758
2759
  { downcase_char(deconst(p)); }
2759
2760
  goto st85;
2760
2761
  st85:
2761
2762
  if ( ++p == pe )
2762
2763
  goto _test_eof85;
2763
2764
  case 85:
2764
- #line 2765 "unicorn_http.c"
2765
+ #line 2766 "unicorn_http.c"
2765
2766
  switch( (*p) ) {
2766
2767
  case 84: goto tr135;
2767
2768
  case 116: goto tr135;
2768
2769
  }
2769
2770
  goto st0;
2770
2771
  tr135:
2771
- #line 293 "unicorn_http.rl"
2772
+ #line 294 "unicorn_http.rl"
2772
2773
  { downcase_char(deconst(p)); }
2773
2774
  goto st86;
2774
2775
  st86:
2775
2776
  if ( ++p == pe )
2776
2777
  goto _test_eof86;
2777
2778
  case 86:
2778
- #line 2779 "unicorn_http.c"
2779
+ #line 2780 "unicorn_http.c"
2779
2780
  switch( (*p) ) {
2780
2781
  case 80: goto tr136;
2781
2782
  case 112: goto tr136;
2782
2783
  }
2783
2784
  goto st0;
2784
2785
  tr136:
2785
- #line 293 "unicorn_http.rl"
2786
+ #line 294 "unicorn_http.rl"
2786
2787
  { downcase_char(deconst(p)); }
2787
2788
  goto st87;
2788
2789
  st87:
2789
2790
  if ( ++p == pe )
2790
2791
  goto _test_eof87;
2791
2792
  case 87:
2792
- #line 2793 "unicorn_http.c"
2793
+ #line 2794 "unicorn_http.c"
2793
2794
  switch( (*p) ) {
2794
2795
  case 58: goto tr137;
2795
2796
  case 83: goto tr138;
@@ -2797,7 +2798,7 @@ case 87:
2797
2798
  }
2798
2799
  goto st0;
2799
2800
  tr137:
2800
- #line 299 "unicorn_http.rl"
2801
+ #line 300 "unicorn_http.rl"
2801
2802
  {
2802
2803
  rb_hash_aset(hp->env, g_rack_url_scheme, STR_NEW(mark, p));
2803
2804
  }
@@ -2806,7 +2807,7 @@ st88:
2806
2807
  if ( ++p == pe )
2807
2808
  goto _test_eof88;
2808
2809
  case 88:
2809
- #line 2810 "unicorn_http.c"
2810
+ #line 2811 "unicorn_http.c"
2810
2811
  if ( (*p) == 47 )
2811
2812
  goto st89;
2812
2813
  goto st0;
@@ -2894,14 +2895,14 @@ case 93:
2894
2895
  goto st91;
2895
2896
  goto st0;
2896
2897
  tr143:
2897
- #line 289 "unicorn_http.rl"
2898
+ #line 290 "unicorn_http.rl"
2898
2899
  {MARK(mark, p); }
2899
2900
  goto st94;
2900
2901
  st94:
2901
2902
  if ( ++p == pe )
2902
2903
  goto _test_eof94;
2903
2904
  case 94:
2904
- #line 2905 "unicorn_http.c"
2905
+ #line 2906 "unicorn_http.c"
2905
2906
  switch( (*p) ) {
2906
2907
  case 37: goto st92;
2907
2908
  case 47: goto tr147;
@@ -2953,14 +2954,14 @@ case 95:
2953
2954
  goto st0;
2954
2955
  goto st91;
2955
2956
  tr144:
2956
- #line 289 "unicorn_http.rl"
2957
+ #line 290 "unicorn_http.rl"
2957
2958
  {MARK(mark, p); }
2958
2959
  goto st96;
2959
2960
  st96:
2960
2961
  if ( ++p == pe )
2961
2962
  goto _test_eof96;
2962
2963
  case 96:
2963
- #line 2964 "unicorn_http.c"
2964
+ #line 2965 "unicorn_http.c"
2964
2965
  switch( (*p) ) {
2965
2966
  case 37: goto st92;
2966
2967
  case 47: goto st0;
@@ -3038,14 +3039,14 @@ case 98:
3038
3039
  goto st0;
3039
3040
  goto st91;
3040
3041
  tr138:
3041
- #line 293 "unicorn_http.rl"
3042
+ #line 294 "unicorn_http.rl"
3042
3043
  { downcase_char(deconst(p)); }
3043
3044
  goto st99;
3044
3045
  st99:
3045
3046
  if ( ++p == pe )
3046
3047
  goto _test_eof99;
3047
3048
  case 99:
3048
- #line 3049 "unicorn_http.c"
3049
+ #line 3050 "unicorn_http.c"
3049
3050
  if ( (*p) == 58 )
3050
3051
  goto tr137;
3051
3052
  goto st0;
@@ -3065,7 +3066,7 @@ case 100:
3065
3066
  goto tr152;
3066
3067
  goto st0;
3067
3068
  tr151:
3068
- #line 338 "unicorn_http.rl"
3069
+ #line 339 "unicorn_http.rl"
3069
3070
  {
3070
3071
  hp->len.chunk = step_incr(hp->len.chunk, (*p), 16);
3071
3072
  if (hp->len.chunk < 0)
@@ -3076,7 +3077,7 @@ st101:
3076
3077
  if ( ++p == pe )
3077
3078
  goto _test_eof101;
3078
3079
  case 101:
3079
- #line 3080 "unicorn_http.c"
3080
+ #line 3081 "unicorn_http.c"
3080
3081
  switch( (*p) ) {
3081
3082
  case 10: goto tr153;
3082
3083
  case 13: goto st102;
@@ -3093,7 +3094,7 @@ case 101:
3093
3094
  goto tr152;
3094
3095
  goto st0;
3095
3096
  tr153:
3096
- #line 367 "unicorn_http.rl"
3097
+ #line 368 "unicorn_http.rl"
3097
3098
  {
3098
3099
  HP_FL_SET(hp, INTRAILER);
3099
3100
  cs = http_parser_en_Trailers;
@@ -3106,7 +3107,7 @@ st123:
3106
3107
  if ( ++p == pe )
3107
3108
  goto _test_eof123;
3108
3109
  case 123:
3109
- #line 3110 "unicorn_http.c"
3110
+ #line 3111 "unicorn_http.c"
3110
3111
  goto st0;
3111
3112
  st102:
3112
3113
  if ( ++p == pe )
@@ -3116,7 +3117,7 @@ case 102:
3116
3117
  goto tr153;
3117
3118
  goto st0;
3118
3119
  tr152:
3119
- #line 338 "unicorn_http.rl"
3120
+ #line 339 "unicorn_http.rl"
3120
3121
  {
3121
3122
  hp->len.chunk = step_incr(hp->len.chunk, (*p), 16);
3122
3123
  if (hp->len.chunk < 0)
@@ -3127,7 +3128,7 @@ st103:
3127
3128
  if ( ++p == pe )
3128
3129
  goto _test_eof103;
3129
3130
  case 103:
3130
- #line 3131 "unicorn_http.c"
3131
+ #line 3132 "unicorn_http.c"
3131
3132
  switch( (*p) ) {
3132
3133
  case 10: goto st104;
3133
3134
  case 13: goto st107;
@@ -3148,7 +3149,7 @@ st104:
3148
3149
  case 104:
3149
3150
  goto tr159;
3150
3151
  tr159:
3151
- #line 375 "unicorn_http.rl"
3152
+ #line 376 "unicorn_http.rl"
3152
3153
  {
3153
3154
  skip_chunk_data_hack: {
3154
3155
  size_t nr = MIN((size_t)hp->len.chunk, REMAINING);
@@ -3170,7 +3171,7 @@ st105:
3170
3171
  if ( ++p == pe )
3171
3172
  goto _test_eof105;
3172
3173
  case 105:
3173
- #line 3174 "unicorn_http.c"
3174
+ #line 3175 "unicorn_http.c"
3174
3175
  switch( (*p) ) {
3175
3176
  case 10: goto st100;
3176
3177
  case 13: goto st106;
@@ -3377,30 +3378,30 @@ case 113:
3377
3378
  goto st113;
3378
3379
  goto st0;
3379
3380
  tr172:
3380
- #line 295 "unicorn_http.rl"
3381
+ #line 296 "unicorn_http.rl"
3381
3382
  { MARK(mark, p); }
3382
- #line 297 "unicorn_http.rl"
3383
+ #line 298 "unicorn_http.rl"
3383
3384
  { write_cont_value(hp, buffer, p); }
3384
3385
  goto st114;
3385
3386
  tr175:
3386
- #line 297 "unicorn_http.rl"
3387
+ #line 298 "unicorn_http.rl"
3387
3388
  { write_cont_value(hp, buffer, p); }
3388
3389
  goto st114;
3389
3390
  tr182:
3390
- #line 295 "unicorn_http.rl"
3391
- { MARK(mark, p); }
3392
3391
  #line 296 "unicorn_http.rl"
3392
+ { MARK(mark, p); }
3393
+ #line 297 "unicorn_http.rl"
3393
3394
  { write_value(hp, buffer, p); }
3394
3395
  goto st114;
3395
3396
  tr185:
3396
- #line 296 "unicorn_http.rl"
3397
+ #line 297 "unicorn_http.rl"
3397
3398
  { write_value(hp, buffer, p); }
3398
3399
  goto st114;
3399
3400
  st114:
3400
3401
  if ( ++p == pe )
3401
3402
  goto _test_eof114;
3402
3403
  case 114:
3403
- #line 3404 "unicorn_http.c"
3404
+ #line 3405 "unicorn_http.c"
3404
3405
  switch( (*p) ) {
3405
3406
  case 9: goto st115;
3406
3407
  case 10: goto tr167;
@@ -3429,14 +3430,14 @@ case 114:
3429
3430
  goto tr169;
3430
3431
  goto st0;
3431
3432
  tr171:
3432
- #line 295 "unicorn_http.rl"
3433
+ #line 296 "unicorn_http.rl"
3433
3434
  { MARK(mark, p); }
3434
3435
  goto st115;
3435
3436
  st115:
3436
3437
  if ( ++p == pe )
3437
3438
  goto _test_eof115;
3438
3439
  case 115:
3439
- #line 3440 "unicorn_http.c"
3440
+ #line 3441 "unicorn_http.c"
3440
3441
  switch( (*p) ) {
3441
3442
  case 9: goto tr171;
3442
3443
  case 10: goto tr172;
@@ -3448,14 +3449,14 @@ case 115:
3448
3449
  goto st0;
3449
3450
  goto tr170;
3450
3451
  tr170:
3451
- #line 295 "unicorn_http.rl"
3452
+ #line 296 "unicorn_http.rl"
3452
3453
  { MARK(mark, p); }
3453
3454
  goto st116;
3454
3455
  st116:
3455
3456
  if ( ++p == pe )
3456
3457
  goto _test_eof116;
3457
3458
  case 116:
3458
- #line 3459 "unicorn_http.c"
3459
+ #line 3460 "unicorn_http.c"
3459
3460
  switch( (*p) ) {
3460
3461
  case 10: goto tr175;
3461
3462
  case 13: goto tr176;
@@ -3468,35 +3469,35 @@ case 116:
3468
3469
  goto st0;
3469
3470
  goto st116;
3470
3471
  tr173:
3471
- #line 295 "unicorn_http.rl"
3472
+ #line 296 "unicorn_http.rl"
3472
3473
  { MARK(mark, p); }
3473
- #line 297 "unicorn_http.rl"
3474
+ #line 298 "unicorn_http.rl"
3474
3475
  { write_cont_value(hp, buffer, p); }
3475
3476
  goto st117;
3476
3477
  tr176:
3477
- #line 297 "unicorn_http.rl"
3478
+ #line 298 "unicorn_http.rl"
3478
3479
  { write_cont_value(hp, buffer, p); }
3479
3480
  goto st117;
3480
3481
  tr183:
3481
- #line 295 "unicorn_http.rl"
3482
- { MARK(mark, p); }
3483
3482
  #line 296 "unicorn_http.rl"
3483
+ { MARK(mark, p); }
3484
+ #line 297 "unicorn_http.rl"
3484
3485
  { write_value(hp, buffer, p); }
3485
3486
  goto st117;
3486
3487
  tr186:
3487
- #line 296 "unicorn_http.rl"
3488
+ #line 297 "unicorn_http.rl"
3488
3489
  { write_value(hp, buffer, p); }
3489
3490
  goto st117;
3490
3491
  st117:
3491
3492
  if ( ++p == pe )
3492
3493
  goto _test_eof117;
3493
3494
  case 117:
3494
- #line 3495 "unicorn_http.c"
3495
+ #line 3496 "unicorn_http.c"
3495
3496
  if ( (*p) == 10 )
3496
3497
  goto st114;
3497
3498
  goto st0;
3498
3499
  tr167:
3499
- #line 362 "unicorn_http.rl"
3500
+ #line 363 "unicorn_http.rl"
3500
3501
  {
3501
3502
  cs = http_parser_first_final;
3502
3503
  goto post_exec;
@@ -3506,7 +3507,7 @@ st124:
3506
3507
  if ( ++p == pe )
3507
3508
  goto _test_eof124;
3508
3509
  case 124:
3509
- #line 3510 "unicorn_http.c"
3510
+ #line 3511 "unicorn_http.c"
3510
3511
  goto st0;
3511
3512
  st118:
3512
3513
  if ( ++p == pe )
@@ -3516,20 +3517,20 @@ case 118:
3516
3517
  goto tr167;
3517
3518
  goto st0;
3518
3519
  tr169:
3519
- #line 291 "unicorn_http.rl"
3520
- { MARK(start.field, p); }
3521
3520
  #line 292 "unicorn_http.rl"
3521
+ { MARK(start.field, p); }
3522
+ #line 293 "unicorn_http.rl"
3522
3523
  { snake_upcase_char(deconst(p)); }
3523
3524
  goto st119;
3524
3525
  tr178:
3525
- #line 292 "unicorn_http.rl"
3526
+ #line 293 "unicorn_http.rl"
3526
3527
  { snake_upcase_char(deconst(p)); }
3527
3528
  goto st119;
3528
3529
  st119:
3529
3530
  if ( ++p == pe )
3530
3531
  goto _test_eof119;
3531
3532
  case 119:
3532
- #line 3533 "unicorn_http.c"
3533
+ #line 3534 "unicorn_http.c"
3533
3534
  switch( (*p) ) {
3534
3535
  case 33: goto tr178;
3535
3536
  case 58: goto tr179;
@@ -3555,18 +3556,18 @@ case 119:
3555
3556
  goto tr178;
3556
3557
  goto st0;
3557
3558
  tr181:
3558
- #line 295 "unicorn_http.rl"
3559
+ #line 296 "unicorn_http.rl"
3559
3560
  { MARK(mark, p); }
3560
3561
  goto st120;
3561
3562
  tr179:
3562
- #line 294 "unicorn_http.rl"
3563
+ #line 295 "unicorn_http.rl"
3563
3564
  { hp->s.field_len = LEN(start.field, p); }
3564
3565
  goto st120;
3565
3566
  st120:
3566
3567
  if ( ++p == pe )
3567
3568
  goto _test_eof120;
3568
3569
  case 120:
3569
- #line 3570 "unicorn_http.c"
3570
+ #line 3571 "unicorn_http.c"
3570
3571
  switch( (*p) ) {
3571
3572
  case 9: goto tr181;
3572
3573
  case 10: goto tr182;
@@ -3578,14 +3579,14 @@ case 120:
3578
3579
  goto st0;
3579
3580
  goto tr180;
3580
3581
  tr180:
3581
- #line 295 "unicorn_http.rl"
3582
+ #line 296 "unicorn_http.rl"
3582
3583
  { MARK(mark, p); }
3583
3584
  goto st121;
3584
3585
  st121:
3585
3586
  if ( ++p == pe )
3586
3587
  goto _test_eof121;
3587
3588
  case 121:
3588
- #line 3589 "unicorn_http.c"
3589
+ #line 3590 "unicorn_http.c"
3589
3590
  switch( (*p) ) {
3590
3591
  case 10: goto tr185;
3591
3592
  case 13: goto tr186;
@@ -3726,7 +3727,7 @@ case 121:
3726
3727
  _out: {}
3727
3728
  }
3728
3729
 
3729
- #line 436 "unicorn_http.rl"
3730
+ #line 437 "unicorn_http.rl"
3730
3731
  post_exec: /* "_out:" also goes here */
3731
3732
  if (hp->cs != http_parser_error)
3732
3733
  hp->cs = cs;
@@ -3901,6 +3902,10 @@ static VALUE HttpParser_clear(VALUE self)
3901
3902
  {
3902
3903
  struct http_parser *hp = data_get(self);
3903
3904
 
3905
+ /* we can't safely reuse .buf and .env if hijacked */
3906
+ if (HP_FL_TEST(hp, HIJACK))
3907
+ return HttpParser_init(self);
3908
+
3904
3909
  http_parser_init(hp);
3905
3910
  my_hash_clear(hp->env);
3906
3911
 
@@ -4107,6 +4112,15 @@ static VALUE HttpParser_env(VALUE self)
4107
4112
  return data_get(self)->env;
4108
4113
  }
4109
4114
 
4115
+ static VALUE HttpParser_hijacked_bang(VALUE self)
4116
+ {
4117
+ struct http_parser *hp = data_get(self);
4118
+
4119
+ HP_FL_SET(hp, HIJACK);
4120
+
4121
+ return self;
4122
+ }
4123
+
4110
4124
  /**
4111
4125
  * call-seq:
4112
4126
  * parser.filter_body(dst, src) => nil/src
@@ -4211,11 +4225,8 @@ static VALUE HttpParser_rssget(VALUE self)
4211
4225
 
4212
4226
  void Init_unicorn_http(void)
4213
4227
  {
4214
- static VALUE mark_ary;
4215
4228
  VALUE mUnicorn, cHttpParser;
4216
4229
 
4217
- mark_ary = rb_ary_new();
4218
- rb_global_variable(&mark_ary);
4219
4230
  mUnicorn = rb_define_module("Unicorn");
4220
4231
  cHttpParser = rb_define_class_under(mUnicorn, "HttpParser", rb_cObject);
4221
4232
  eHttpParserError =
@@ -4225,7 +4236,7 @@ void Init_unicorn_http(void)
4225
4236
  e414 = rb_define_class_under(mUnicorn, "RequestURITooLongError",
4226
4237
  eHttpParserError);
4227
4238
 
4228
- init_globals(mark_ary);
4239
+ init_globals();
4229
4240
  rb_define_alloc_func(cHttpParser, HttpParser_alloc);
4230
4241
  rb_define_method(cHttpParser, "initialize", HttpParser_init, 0);
4231
4242
  rb_define_method(cHttpParser, "clear", HttpParser_clear, 0);
@@ -4241,6 +4252,7 @@ void Init_unicorn_http(void)
4241
4252
  rb_define_method(cHttpParser, "next?", HttpParser_next, 0);
4242
4253
  rb_define_method(cHttpParser, "buf", HttpParser_buf, 0);
4243
4254
  rb_define_method(cHttpParser, "env", HttpParser_env, 0);
4255
+ rb_define_method(cHttpParser, "hijacked!", HttpParser_hijacked_bang, 0);
4244
4256
  rb_define_method(cHttpParser, "response_start_sent=", HttpParser_rssset, 1);
4245
4257
  rb_define_method(cHttpParser, "response_start_sent", HttpParser_rssget, 0);
4246
4258
 
@@ -4261,16 +4273,14 @@ void Init_unicorn_http(void)
4261
4273
 
4262
4274
  rb_define_singleton_method(cHttpParser, "max_header_len=", set_maxhdrlen, 1);
4263
4275
 
4264
- init_common_fields(mark_ary);
4276
+ init_common_fields();
4265
4277
  SET_GLOBAL(g_http_host, "HOST");
4266
4278
  SET_GLOBAL(g_http_trailer, "TRAILER");
4267
4279
  SET_GLOBAL(g_http_transfer_encoding, "TRANSFER_ENCODING");
4268
4280
  SET_GLOBAL(g_content_length, "CONTENT_LENGTH");
4269
4281
  SET_GLOBAL(g_http_connection, "CONNECTION");
4270
4282
  id_set_backtrace = rb_intern("set_backtrace");
4271
- init_unicorn_httpdate(mark_ary);
4272
-
4273
- OBJ_FREEZE(mark_ary);
4283
+ init_unicorn_httpdate();
4274
4284
 
4275
4285
  #ifndef HAVE_RB_HASH_CLEAR
4276
4286
  id_clear = rb_intern("clear");