pitchfork 0.18.2 → 0.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -182,12 +182,6 @@ http_version(struct http_parser *hp, const char *ptr, size_t len)
182
182
  rb_hash_aset(hp->env, g_http_version, v);
183
183
  }
184
184
 
185
- static inline void hp_invalid_if_trailer(struct http_parser *hp)
186
- {
187
- if (HP_FL_TEST(hp, INTRAILER))
188
- parser_raise(eHttpParserError, "invalid Trailer");
189
- }
190
-
191
185
  static void write_cont_value(struct http_parser *hp,
192
186
  char *buffer, const char *p)
193
187
  {
@@ -238,16 +232,42 @@ static int is_chunked(VALUE v)
238
232
  }
239
233
 
240
234
  static void write_value(VALUE self, struct http_parser *hp,
241
- const char *buffer, const char *p)
235
+ char *buffer, const char *p)
242
236
  {
243
- VALUE f = find_common_field(PTR_TO(start.field), hp->s.field_len);
237
+ VALUE f;
238
+ char *field = PTR_TO(start.field);
239
+ size_t i;
240
+ VALUE target = hp->env;
244
241
  VALUE v;
245
242
  VALUE e;
243
+ int in_trailer = HP_FL_TEST(hp, INTRAILER);
244
+
245
+ /* Reject ambiguous framing headers before normalizing dashes for Rack. */
246
+ if (CONST_MEM_EQ("CONTENT_LENGTH", field, hp->s.field_len))
247
+ parser_raise(eHttpParserError, "invalid Content-Length");
248
+ if (CONST_MEM_EQ("TRANSFER_ENCODING", field, hp->s.field_len))
249
+ parser_raise(eHttpParserError, "invalid Transfer-Encoding");
250
+
251
+ if (memchr(field, '_', hp->s.field_len)) {
252
+ VALIDATE_MAX_LENGTH(hp->s.field_len, FIELD_NAME);
253
+ VALIDATE_MAX_LENGTH(LEN(mark, p), FIELD_VALUE);
254
+ RB_OBJ_WRITE(self, &hp->cont, Qnil);
255
+ return;
256
+ }
257
+
258
+ for (i = 0; i < hp->s.field_len; i++)
259
+ if (field[i] == '-')
260
+ field[i] = '_';
261
+
262
+ f = find_common_field(field, hp->s.field_len);
246
263
 
247
264
  VALIDATE_MAX_LENGTH(LEN(mark, p), FIELD_VALUE);
265
+ if (in_trailer && (f == g_content_length ||
266
+ f == g_http_transfer_encoding || f == g_http_trailer))
267
+ parser_raise(eHttpParserError, "invalid Trailer");
268
+
248
269
  v = LEN(mark, p) == 0 ? rb_str_buf_new(128) : STRIPPED_STR_NEW(mark, p);
249
270
  if (NIL_P(f)) {
250
- const char *field = PTR_TO(start.field);
251
271
  size_t flen = hp->s.field_len;
252
272
 
253
273
  VALIDATE_MAX_LENGTH(flen, FIELD_NAME);
@@ -256,14 +276,14 @@ static void write_value(VALUE self, struct http_parser *hp,
256
276
  * ignore "Version" headers since they conflict with the HTTP_VERSION
257
277
  * rack env variable.
258
278
  */
259
- if (CONST_MEM_EQ("VERSION", field, flen)) {
279
+ if (!in_trailer && CONST_MEM_EQ("VERSION", field, flen)) {
260
280
  RB_OBJ_WRITE(self, &hp->cont, Qnil);
261
281
  return;
262
282
  }
263
283
  f = uncommon_field(field, flen);
264
- } else if (f == g_http_connection) {
284
+ } else if (!in_trailer && f == g_http_connection) {
265
285
  hp_keepalive_connection(hp, v);
266
- } else if (f == g_content_length && !HP_FL_TEST(hp, CHUNKED)) {
286
+ } else if (!in_trailer && f == g_content_length && !HP_FL_TEST(hp, CHUNKED)) {
267
287
  if (hp->len.content)
268
288
  parser_raise(eHttpParserError, "Content-Length already set");
269
289
  hp->len.content = parse_length(RSTRING_PTR(v), RSTRING_LEN(v));
@@ -271,8 +291,7 @@ static void write_value(VALUE self, struct http_parser *hp,
271
291
  parser_raise(eHttpParserError, "invalid Content-Length");
272
292
  if (hp->len.content != 0)
273
293
  HP_FL_SET(hp, HASBODY);
274
- hp_invalid_if_trailer(hp);
275
- } else if (f == g_http_transfer_encoding) {
294
+ } else if (!in_trailer && f == g_http_transfer_encoding) {
276
295
  if (is_chunked(v)) {
277
296
  if (HP_FL_TEST(hp, CHUNKED))
278
297
  /*
@@ -298,19 +317,25 @@ static void write_value(VALUE self, struct http_parser *hp,
298
317
  */
299
318
  parser_raise(eHttpParserError, "invalid Transfer-Encoding");
300
319
  }
301
- hp_invalid_if_trailer(hp);
302
- } else if (f == g_http_trailer) {
320
+ } else if (!in_trailer && f == g_http_trailer) {
303
321
  HP_FL_SET(hp, HASTRAILER);
304
- hp_invalid_if_trailer(hp);
305
322
  } else {
306
323
  assert(TYPE(f) == T_STRING && "memoized object is not a string");
307
324
  assert_frozen(f);
308
325
  }
309
326
 
310
- e = rb_hash_aref(hp->env, f);
327
+ if (in_trailer) {
328
+ target = rb_hash_aref(hp->env, g_request_trailers);
329
+ if (NIL_P(target)) {
330
+ target = rb_hash_new();
331
+ rb_hash_aset(hp->env, g_request_trailers, target);
332
+ }
333
+ }
334
+
335
+ e = rb_hash_aref(target, f);
311
336
  if (NIL_P(e)) {
312
- RB_OBJ_WRITE(self, &hp->cont, rb_hash_aset(hp->env, f, v));
313
- } else if (f == g_http_host) {
337
+ RB_OBJ_WRITE(self, &hp->cont, rb_hash_aset(target, f, v));
338
+ } else if (!in_trailer && f == g_http_host) {
314
339
  /*
315
340
  * ignored, absolute URLs in REQUEST_URI take precedence over
316
341
  * the Host: header (ref: rfc 2616, section 5.2.1)
@@ -325,12 +350,12 @@ static void write_value(VALUE self, struct http_parser *hp,
325
350
  /** Machine **/
326
351
 
327
352
 
328
- #line 425 "pitchfork_http.rl"
353
+ #line 451 "pitchfork_http.rl"
329
354
 
330
355
 
331
356
  /** Data **/
332
357
 
333
- #line 334 "pitchfork_http.c"
358
+ #line 359 "pitchfork_http.c"
334
359
  static const int http_parser_start = 1;
335
360
  static const int http_parser_first_final = 122;
336
361
  static const int http_parser_error = 0;
@@ -341,7 +366,7 @@ static const int http_parser_en_Trailers = 114;
341
366
  static const int http_parser_en_main = 1;
342
367
 
343
368
 
344
- #line 429 "pitchfork_http.rl"
369
+ #line 455 "pitchfork_http.rl"
345
370
 
346
371
  static void http_parser_init(struct http_parser *hp)
347
372
  {
@@ -354,12 +379,12 @@ static void http_parser_init(struct http_parser *hp)
354
379
  hp->len.content = 0;
355
380
  hp->cont = Qfalse; /* zero on MRI, should be optimized away by above */
356
381
 
357
- #line 358 "pitchfork_http.c"
382
+ #line 383 "pitchfork_http.c"
358
383
  {
359
384
  cs = http_parser_start;
360
385
  }
361
386
 
362
- #line 441 "pitchfork_http.rl"
387
+ #line 467 "pitchfork_http.rl"
363
388
  hp->cs = cs;
364
389
  }
365
390
 
@@ -387,7 +412,7 @@ http_parser_execute(VALUE self, struct http_parser *hp, char *buffer, size_t len
387
412
  goto skip_chunk_data_hack;
388
413
  }
389
414
 
390
- #line 391 "pitchfork_http.c"
415
+ #line 416 "pitchfork_http.c"
391
416
  {
392
417
  if ( p == pe )
393
418
  goto _test_eof;
@@ -422,14 +447,14 @@ st0:
422
447
  cs = 0;
423
448
  goto _out;
424
449
  tr0:
425
- #line 328 "pitchfork_http.rl"
450
+ #line 353 "pitchfork_http.rl"
426
451
  {MARK(mark, p); }
427
452
  goto st2;
428
453
  st2:
429
454
  if ( ++p == pe )
430
455
  goto _test_eof2;
431
456
  case 2:
432
- #line 433 "pitchfork_http.c"
457
+ #line 458 "pitchfork_http.c"
433
458
  switch( (*p) ) {
434
459
  case 32: goto tr3;
435
460
  case 33: goto st49;
@@ -455,14 +480,14 @@ case 2:
455
480
  goto st49;
456
481
  goto st0;
457
482
  tr3:
458
- #line 337 "pitchfork_http.rl"
483
+ #line 362 "pitchfork_http.rl"
459
484
  { request_method(hp, PTR_TO(mark), LEN(mark, p)); }
460
485
  goto st3;
461
486
  st3:
462
487
  if ( ++p == pe )
463
488
  goto _test_eof3;
464
489
  case 3:
465
- #line 466 "pitchfork_http.c"
490
+ #line 491 "pitchfork_http.c"
466
491
  switch( (*p) ) {
467
492
  case 42: goto tr5;
468
493
  case 47: goto tr6;
@@ -471,21 +496,21 @@ case 3:
471
496
  }
472
497
  goto st0;
473
498
  tr5:
474
- #line 328 "pitchfork_http.rl"
499
+ #line 353 "pitchfork_http.rl"
475
500
  {MARK(mark, p); }
476
501
  goto st4;
477
502
  st4:
478
503
  if ( ++p == pe )
479
504
  goto _test_eof4;
480
505
  case 4:
481
- #line 482 "pitchfork_http.c"
506
+ #line 507 "pitchfork_http.c"
482
507
  switch( (*p) ) {
483
508
  case 32: goto tr8;
484
509
  case 35: goto tr9;
485
510
  }
486
511
  goto st0;
487
512
  tr8:
488
- #line 342 "pitchfork_http.rl"
513
+ #line 367 "pitchfork_http.rl"
489
514
  {
490
515
  VALUE str;
491
516
 
@@ -497,24 +522,24 @@ tr8:
497
522
  }
498
523
  }
499
524
  goto st5;
500
- tr42:
501
- #line 328 "pitchfork_http.rl"
525
+ tr41:
526
+ #line 353 "pitchfork_http.rl"
502
527
  {MARK(mark, p); }
503
- #line 352 "pitchfork_http.rl"
528
+ #line 377 "pitchfork_http.rl"
504
529
  {
505
530
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
506
531
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
507
532
  }
508
533
  goto st5;
509
- tr45:
510
- #line 352 "pitchfork_http.rl"
534
+ tr44:
535
+ #line 377 "pitchfork_http.rl"
511
536
  {
512
537
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
513
538
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
514
539
  }
515
540
  goto st5;
516
- tr49:
517
- #line 362 "pitchfork_http.rl"
541
+ tr48:
542
+ #line 387 "pitchfork_http.rl"
518
543
  {
519
544
  VALUE val;
520
545
 
@@ -523,7 +548,7 @@ tr49:
523
548
 
524
549
  rb_hash_aset(hp->env, g_path_info, val);
525
550
  }
526
- #line 342 "pitchfork_http.rl"
551
+ #line 367 "pitchfork_http.rl"
527
552
  {
528
553
  VALUE str;
529
554
 
@@ -535,15 +560,15 @@ tr49:
535
560
  }
536
561
  }
537
562
  goto st5;
538
- tr55:
539
- #line 356 "pitchfork_http.rl"
563
+ tr54:
564
+ #line 381 "pitchfork_http.rl"
540
565
  {MARK(start.query, p); }
541
- #line 357 "pitchfork_http.rl"
566
+ #line 382 "pitchfork_http.rl"
542
567
  {
543
568
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
544
569
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
545
570
  }
546
- #line 342 "pitchfork_http.rl"
571
+ #line 367 "pitchfork_http.rl"
547
572
  {
548
573
  VALUE str;
549
574
 
@@ -555,13 +580,13 @@ tr55:
555
580
  }
556
581
  }
557
582
  goto st5;
558
- tr59:
559
- #line 357 "pitchfork_http.rl"
583
+ tr58:
584
+ #line 382 "pitchfork_http.rl"
560
585
  {
561
586
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
562
587
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
563
588
  }
564
- #line 342 "pitchfork_http.rl"
589
+ #line 367 "pitchfork_http.rl"
565
590
  {
566
591
  VALUE str;
567
592
 
@@ -577,19 +602,19 @@ st5:
577
602
  if ( ++p == pe )
578
603
  goto _test_eof5;
579
604
  case 5:
580
- #line 581 "pitchfork_http.c"
605
+ #line 606 "pitchfork_http.c"
581
606
  if ( (*p) == 72 )
582
607
  goto tr10;
583
608
  goto st0;
584
609
  tr10:
585
- #line 328 "pitchfork_http.rl"
610
+ #line 353 "pitchfork_http.rl"
586
611
  {MARK(mark, p); }
587
612
  goto st6;
588
613
  st6:
589
614
  if ( ++p == pe )
590
615
  goto _test_eof6;
591
616
  case 6:
592
- #line 593 "pitchfork_http.c"
617
+ #line 618 "pitchfork_http.c"
593
618
  if ( (*p) == 84 )
594
619
  goto st7;
595
620
  goto st0;
@@ -649,34 +674,34 @@ case 13:
649
674
  goto st13;
650
675
  goto st0;
651
676
  tr18:
652
- #line 361 "pitchfork_http.rl"
677
+ #line 386 "pitchfork_http.rl"
653
678
  { http_version(hp, PTR_TO(mark), LEN(mark, p)); }
654
679
  goto st14;
655
- tr26:
656
- #line 334 "pitchfork_http.rl"
680
+ tr25:
681
+ #line 359 "pitchfork_http.rl"
657
682
  { MARK(mark, p); }
658
- #line 336 "pitchfork_http.rl"
683
+ #line 361 "pitchfork_http.rl"
659
684
  { write_cont_value(hp, buffer, p); }
660
685
  goto st14;
661
- tr29:
662
- #line 336 "pitchfork_http.rl"
686
+ tr30:
687
+ #line 361 "pitchfork_http.rl"
663
688
  { write_cont_value(hp, buffer, p); }
664
689
  goto st14;
665
- tr36:
666
- #line 334 "pitchfork_http.rl"
690
+ tr35:
691
+ #line 359 "pitchfork_http.rl"
667
692
  { MARK(mark, p); }
668
- #line 335 "pitchfork_http.rl"
693
+ #line 360 "pitchfork_http.rl"
669
694
  { write_value(self, hp, buffer, p); }
670
695
  goto st14;
671
696
  tr39:
672
- #line 335 "pitchfork_http.rl"
697
+ #line 360 "pitchfork_http.rl"
673
698
  { write_value(self, hp, buffer, p); }
674
699
  goto st14;
675
700
  st14:
676
701
  if ( ++p == pe )
677
702
  goto _test_eof14;
678
703
  case 14:
679
- #line 680 "pitchfork_http.c"
704
+ #line 705 "pitchfork_http.c"
680
705
  switch( (*p) ) {
681
706
  case 9: goto st15;
682
707
  case 10: goto tr21;
@@ -704,79 +729,79 @@ case 14:
704
729
  } else
705
730
  goto tr23;
706
731
  goto st0;
707
- tr25:
708
- #line 334 "pitchfork_http.rl"
732
+ tr24:
733
+ #line 359 "pitchfork_http.rl"
709
734
  { MARK(mark, p); }
710
735
  goto st15;
711
736
  st15:
712
737
  if ( ++p == pe )
713
738
  goto _test_eof15;
714
739
  case 15:
715
- #line 716 "pitchfork_http.c"
716
- switch( (*p) ) {
717
- case 9: goto tr25;
718
- case 10: goto tr26;
719
- case 13: goto tr27;
720
- case 32: goto tr25;
721
- case 127: goto st0;
722
- }
723
- if ( 0 <= (*p) && (*p) <= 31 )
724
- goto st0;
725
- goto tr24;
726
- tr24:
727
- #line 334 "pitchfork_http.rl"
728
- { MARK(mark, p); }
729
- goto st16;
730
- st16:
731
- if ( ++p == pe )
732
- goto _test_eof16;
733
- case 16:
734
- #line 735 "pitchfork_http.c"
740
+ #line 741 "pitchfork_http.c"
735
741
  switch( (*p) ) {
736
- case 10: goto tr29;
737
- case 13: goto tr30;
742
+ case 9: goto tr24;
743
+ case 10: goto tr25;
744
+ case 13: goto tr26;
745
+ case 32: goto tr24;
738
746
  case 127: goto st0;
739
747
  }
740
- if ( (*p) > 8 ) {
741
- if ( 11 <= (*p) && (*p) <= 31 )
742
- goto st0;
743
- } else if ( (*p) >= 0 )
748
+ if ( (*p) <= 31 )
744
749
  goto st0;
745
- goto st16;
750
+ goto tr27;
746
751
  tr19:
747
- #line 361 "pitchfork_http.rl"
752
+ #line 386 "pitchfork_http.rl"
748
753
  { http_version(hp, PTR_TO(mark), LEN(mark, p)); }
749
- goto st17;
750
- tr27:
751
- #line 334 "pitchfork_http.rl"
754
+ goto st16;
755
+ tr26:
756
+ #line 359 "pitchfork_http.rl"
752
757
  { MARK(mark, p); }
753
- #line 336 "pitchfork_http.rl"
758
+ #line 361 "pitchfork_http.rl"
754
759
  { write_cont_value(hp, buffer, p); }
755
- goto st17;
756
- tr30:
757
- #line 336 "pitchfork_http.rl"
760
+ goto st16;
761
+ tr31:
762
+ #line 361 "pitchfork_http.rl"
758
763
  { write_cont_value(hp, buffer, p); }
759
- goto st17;
760
- tr37:
761
- #line 334 "pitchfork_http.rl"
764
+ goto st16;
765
+ tr36:
766
+ #line 359 "pitchfork_http.rl"
762
767
  { MARK(mark, p); }
763
- #line 335 "pitchfork_http.rl"
768
+ #line 360 "pitchfork_http.rl"
764
769
  { write_value(self, hp, buffer, p); }
765
- goto st17;
770
+ goto st16;
766
771
  tr40:
767
- #line 335 "pitchfork_http.rl"
772
+ #line 360 "pitchfork_http.rl"
768
773
  { write_value(self, hp, buffer, p); }
774
+ goto st16;
775
+ st16:
776
+ if ( ++p == pe )
777
+ goto _test_eof16;
778
+ case 16:
779
+ #line 780 "pitchfork_http.c"
780
+ if ( (*p) == 10 )
781
+ goto st14;
782
+ goto st0;
783
+ tr27:
784
+ #line 359 "pitchfork_http.rl"
785
+ { MARK(mark, p); }
769
786
  goto st17;
770
787
  st17:
771
788
  if ( ++p == pe )
772
789
  goto _test_eof17;
773
790
  case 17:
774
- #line 775 "pitchfork_http.c"
775
- if ( (*p) == 10 )
776
- goto st14;
777
- goto st0;
791
+ #line 792 "pitchfork_http.c"
792
+ switch( (*p) ) {
793
+ case 10: goto tr30;
794
+ case 13: goto tr31;
795
+ case 127: goto st0;
796
+ }
797
+ if ( (*p) > 8 ) {
798
+ if ( 11 <= (*p) && (*p) <= 31 )
799
+ goto st0;
800
+ } else
801
+ goto st0;
802
+ goto st17;
778
803
  tr21:
779
- #line 375 "pitchfork_http.rl"
804
+ #line 400 "pitchfork_http.rl"
780
805
  {
781
806
  finalize_header(hp);
782
807
 
@@ -797,7 +822,7 @@ tr21:
797
822
  }
798
823
  goto st122;
799
824
  tr104:
800
- #line 342 "pitchfork_http.rl"
825
+ #line 367 "pitchfork_http.rl"
801
826
  {
802
827
  VALUE str;
803
828
 
@@ -808,7 +833,7 @@ tr104:
808
833
  rb_hash_aset(hp->env, g_path_info, str);
809
834
  }
810
835
  }
811
- #line 375 "pitchfork_http.rl"
836
+ #line 400 "pitchfork_http.rl"
812
837
  {
813
838
  finalize_header(hp);
814
839
 
@@ -828,15 +853,15 @@ tr104:
828
853
  goto post_exec;
829
854
  }
830
855
  goto st122;
831
- tr108:
832
- #line 328 "pitchfork_http.rl"
856
+ tr107:
857
+ #line 353 "pitchfork_http.rl"
833
858
  {MARK(mark, p); }
834
- #line 352 "pitchfork_http.rl"
859
+ #line 377 "pitchfork_http.rl"
835
860
  {
836
861
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
837
862
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
838
863
  }
839
- #line 375 "pitchfork_http.rl"
864
+ #line 400 "pitchfork_http.rl"
840
865
  {
841
866
  finalize_header(hp);
842
867
 
@@ -856,13 +881,13 @@ tr108:
856
881
  goto post_exec;
857
882
  }
858
883
  goto st122;
859
- tr112:
860
- #line 352 "pitchfork_http.rl"
884
+ tr111:
885
+ #line 377 "pitchfork_http.rl"
861
886
  {
862
887
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
863
888
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
864
889
  }
865
- #line 375 "pitchfork_http.rl"
890
+ #line 400 "pitchfork_http.rl"
866
891
  {
867
892
  finalize_header(hp);
868
893
 
@@ -882,8 +907,8 @@ tr112:
882
907
  goto post_exec;
883
908
  }
884
909
  goto st122;
885
- tr117:
886
- #line 362 "pitchfork_http.rl"
910
+ tr116:
911
+ #line 387 "pitchfork_http.rl"
887
912
  {
888
913
  VALUE val;
889
914
 
@@ -892,7 +917,7 @@ tr117:
892
917
 
893
918
  rb_hash_aset(hp->env, g_path_info, val);
894
919
  }
895
- #line 342 "pitchfork_http.rl"
920
+ #line 367 "pitchfork_http.rl"
896
921
  {
897
922
  VALUE str;
898
923
 
@@ -903,7 +928,7 @@ tr117:
903
928
  rb_hash_aset(hp->env, g_path_info, str);
904
929
  }
905
930
  }
906
- #line 375 "pitchfork_http.rl"
931
+ #line 400 "pitchfork_http.rl"
907
932
  {
908
933
  finalize_header(hp);
909
934
 
@@ -923,15 +948,15 @@ tr117:
923
948
  goto post_exec;
924
949
  }
925
950
  goto st122;
926
- tr124:
927
- #line 356 "pitchfork_http.rl"
951
+ tr123:
952
+ #line 381 "pitchfork_http.rl"
928
953
  {MARK(start.query, p); }
929
- #line 357 "pitchfork_http.rl"
954
+ #line 382 "pitchfork_http.rl"
930
955
  {
931
956
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
932
957
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
933
958
  }
934
- #line 342 "pitchfork_http.rl"
959
+ #line 367 "pitchfork_http.rl"
935
960
  {
936
961
  VALUE str;
937
962
 
@@ -942,7 +967,7 @@ tr124:
942
967
  rb_hash_aset(hp->env, g_path_info, str);
943
968
  }
944
969
  }
945
- #line 375 "pitchfork_http.rl"
970
+ #line 400 "pitchfork_http.rl"
946
971
  {
947
972
  finalize_header(hp);
948
973
 
@@ -962,13 +987,13 @@ tr124:
962
987
  goto post_exec;
963
988
  }
964
989
  goto st122;
965
- tr129:
966
- #line 357 "pitchfork_http.rl"
990
+ tr128:
991
+ #line 382 "pitchfork_http.rl"
967
992
  {
968
993
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
969
994
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
970
995
  }
971
- #line 342 "pitchfork_http.rl"
996
+ #line 367 "pitchfork_http.rl"
972
997
  {
973
998
  VALUE str;
974
999
 
@@ -979,7 +1004,7 @@ tr129:
979
1004
  rb_hash_aset(hp->env, g_path_info, str);
980
1005
  }
981
1006
  }
982
- #line 375 "pitchfork_http.rl"
1007
+ #line 400 "pitchfork_http.rl"
983
1008
  {
984
1009
  finalize_header(hp);
985
1010
 
@@ -1003,10 +1028,10 @@ st122:
1003
1028
  if ( ++p == pe )
1004
1029
  goto _test_eof122;
1005
1030
  case 122:
1006
- #line 1007 "pitchfork_http.c"
1031
+ #line 1032 "pitchfork_http.c"
1007
1032
  goto st0;
1008
1033
  tr105:
1009
- #line 342 "pitchfork_http.rl"
1034
+ #line 367 "pitchfork_http.rl"
1010
1035
  {
1011
1036
  VALUE str;
1012
1037
 
@@ -1018,24 +1043,24 @@ tr105:
1018
1043
  }
1019
1044
  }
1020
1045
  goto st18;
1021
- tr109:
1022
- #line 328 "pitchfork_http.rl"
1046
+ tr108:
1047
+ #line 353 "pitchfork_http.rl"
1023
1048
  {MARK(mark, p); }
1024
- #line 352 "pitchfork_http.rl"
1049
+ #line 377 "pitchfork_http.rl"
1025
1050
  {
1026
1051
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
1027
1052
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
1028
1053
  }
1029
1054
  goto st18;
1030
- tr113:
1031
- #line 352 "pitchfork_http.rl"
1055
+ tr112:
1056
+ #line 377 "pitchfork_http.rl"
1032
1057
  {
1033
1058
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
1034
1059
  rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
1035
1060
  }
1036
1061
  goto st18;
1037
- tr118:
1038
- #line 362 "pitchfork_http.rl"
1062
+ tr117:
1063
+ #line 387 "pitchfork_http.rl"
1039
1064
  {
1040
1065
  VALUE val;
1041
1066
 
@@ -1044,7 +1069,7 @@ tr118:
1044
1069
 
1045
1070
  rb_hash_aset(hp->env, g_path_info, val);
1046
1071
  }
1047
- #line 342 "pitchfork_http.rl"
1072
+ #line 367 "pitchfork_http.rl"
1048
1073
  {
1049
1074
  VALUE str;
1050
1075
 
@@ -1056,15 +1081,15 @@ tr118:
1056
1081
  }
1057
1082
  }
1058
1083
  goto st18;
1059
- tr125:
1060
- #line 356 "pitchfork_http.rl"
1084
+ tr124:
1085
+ #line 381 "pitchfork_http.rl"
1061
1086
  {MARK(start.query, p); }
1062
- #line 357 "pitchfork_http.rl"
1087
+ #line 382 "pitchfork_http.rl"
1063
1088
  {
1064
1089
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1065
1090
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1066
1091
  }
1067
- #line 342 "pitchfork_http.rl"
1092
+ #line 367 "pitchfork_http.rl"
1068
1093
  {
1069
1094
  VALUE str;
1070
1095
 
@@ -1076,13 +1101,13 @@ tr125:
1076
1101
  }
1077
1102
  }
1078
1103
  goto st18;
1079
- tr130:
1080
- #line 357 "pitchfork_http.rl"
1104
+ tr129:
1105
+ #line 382 "pitchfork_http.rl"
1081
1106
  {
1082
1107
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1083
1108
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1084
1109
  }
1085
- #line 342 "pitchfork_http.rl"
1110
+ #line 367 "pitchfork_http.rl"
1086
1111
  {
1087
1112
  VALUE str;
1088
1113
 
@@ -1098,25 +1123,25 @@ st18:
1098
1123
  if ( ++p == pe )
1099
1124
  goto _test_eof18;
1100
1125
  case 18:
1101
- #line 1102 "pitchfork_http.c"
1126
+ #line 1127 "pitchfork_http.c"
1102
1127
  if ( (*p) == 10 )
1103
1128
  goto tr21;
1104
1129
  goto st0;
1105
1130
  tr23:
1106
- #line 330 "pitchfork_http.rl"
1131
+ #line 355 "pitchfork_http.rl"
1107
1132
  { MARK(start.field, p); }
1108
- #line 331 "pitchfork_http.rl"
1109
- { snake_upcase_char(deconst(p)); }
1133
+ #line 356 "pitchfork_http.rl"
1134
+ { upcase_char(deconst(p)); }
1110
1135
  goto st19;
1111
1136
  tr32:
1112
- #line 331 "pitchfork_http.rl"
1113
- { snake_upcase_char(deconst(p)); }
1137
+ #line 356 "pitchfork_http.rl"
1138
+ { upcase_char(deconst(p)); }
1114
1139
  goto st19;
1115
1140
  st19:
1116
1141
  if ( ++p == pe )
1117
1142
  goto _test_eof19;
1118
1143
  case 19:
1119
- #line 1120 "pitchfork_http.c"
1144
+ #line 1145 "pitchfork_http.c"
1120
1145
  switch( (*p) ) {
1121
1146
  case 33: goto tr32;
1122
1147
  case 58: goto tr33;
@@ -1141,38 +1166,38 @@ case 19:
1141
1166
  } else
1142
1167
  goto tr32;
1143
1168
  goto st0;
1144
- tr35:
1145
- #line 334 "pitchfork_http.rl"
1169
+ tr34:
1170
+ #line 359 "pitchfork_http.rl"
1146
1171
  { MARK(mark, p); }
1147
1172
  goto st20;
1148
1173
  tr33:
1149
- #line 333 "pitchfork_http.rl"
1174
+ #line 358 "pitchfork_http.rl"
1150
1175
  { hp->s.field_len = LEN(start.field, p); }
1151
1176
  goto st20;
1152
1177
  st20:
1153
1178
  if ( ++p == pe )
1154
1179
  goto _test_eof20;
1155
1180
  case 20:
1156
- #line 1157 "pitchfork_http.c"
1181
+ #line 1182 "pitchfork_http.c"
1157
1182
  switch( (*p) ) {
1158
- case 9: goto tr35;
1159
- case 10: goto tr36;
1160
- case 13: goto tr37;
1161
- case 32: goto tr35;
1183
+ case 9: goto tr34;
1184
+ case 10: goto tr35;
1185
+ case 13: goto tr36;
1186
+ case 32: goto tr34;
1162
1187
  case 127: goto st0;
1163
1188
  }
1164
- if ( 0 <= (*p) && (*p) <= 31 )
1189
+ if ( (*p) <= 31 )
1165
1190
  goto st0;
1166
- goto tr34;
1167
- tr34:
1168
- #line 334 "pitchfork_http.rl"
1191
+ goto tr37;
1192
+ tr37:
1193
+ #line 359 "pitchfork_http.rl"
1169
1194
  { MARK(mark, p); }
1170
1195
  goto st21;
1171
1196
  st21:
1172
1197
  if ( ++p == pe )
1173
1198
  goto _test_eof21;
1174
1199
  case 21:
1175
- #line 1176 "pitchfork_http.c"
1200
+ #line 1201 "pitchfork_http.c"
1176
1201
  switch( (*p) ) {
1177
1202
  case 10: goto tr39;
1178
1203
  case 13: goto tr40;
@@ -1181,11 +1206,11 @@ case 21:
1181
1206
  if ( (*p) > 8 ) {
1182
1207
  if ( 11 <= (*p) && (*p) <= 31 )
1183
1208
  goto st0;
1184
- } else if ( (*p) >= 0 )
1209
+ } else
1185
1210
  goto st0;
1186
1211
  goto st21;
1187
1212
  tr9:
1188
- #line 342 "pitchfork_http.rl"
1213
+ #line 367 "pitchfork_http.rl"
1189
1214
  {
1190
1215
  VALUE str;
1191
1216
 
@@ -1198,7 +1223,7 @@ tr9:
1198
1223
  }
1199
1224
  goto st22;
1200
1225
  tr50:
1201
- #line 362 "pitchfork_http.rl"
1226
+ #line 387 "pitchfork_http.rl"
1202
1227
  {
1203
1228
  VALUE val;
1204
1229
 
@@ -1207,7 +1232,7 @@ tr50:
1207
1232
 
1208
1233
  rb_hash_aset(hp->env, g_path_info, val);
1209
1234
  }
1210
- #line 342 "pitchfork_http.rl"
1235
+ #line 367 "pitchfork_http.rl"
1211
1236
  {
1212
1237
  VALUE str;
1213
1238
 
@@ -1220,14 +1245,14 @@ tr50:
1220
1245
  }
1221
1246
  goto st22;
1222
1247
  tr56:
1223
- #line 356 "pitchfork_http.rl"
1248
+ #line 381 "pitchfork_http.rl"
1224
1249
  {MARK(start.query, p); }
1225
- #line 357 "pitchfork_http.rl"
1250
+ #line 382 "pitchfork_http.rl"
1226
1251
  {
1227
1252
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1228
1253
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1229
1254
  }
1230
- #line 342 "pitchfork_http.rl"
1255
+ #line 367 "pitchfork_http.rl"
1231
1256
  {
1232
1257
  VALUE str;
1233
1258
 
@@ -1240,12 +1265,12 @@ tr56:
1240
1265
  }
1241
1266
  goto st22;
1242
1267
  tr60:
1243
- #line 357 "pitchfork_http.rl"
1268
+ #line 382 "pitchfork_http.rl"
1244
1269
  {
1245
1270
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1246
1271
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1247
1272
  }
1248
- #line 342 "pitchfork_http.rl"
1273
+ #line 367 "pitchfork_http.rl"
1249
1274
  {
1250
1275
  VALUE str;
1251
1276
 
@@ -1261,43 +1286,43 @@ st22:
1261
1286
  if ( ++p == pe )
1262
1287
  goto _test_eof22;
1263
1288
  case 22:
1264
- #line 1265 "pitchfork_http.c"
1289
+ #line 1290 "pitchfork_http.c"
1265
1290
  switch( (*p) ) {
1266
- case 32: goto tr42;
1291
+ case 32: goto tr41;
1267
1292
  case 35: goto st0;
1268
1293
  case 37: goto tr43;
1269
1294
  case 127: goto st0;
1270
1295
  }
1271
- if ( 0 <= (*p) && (*p) <= 31 )
1296
+ if ( (*p) <= 31 )
1272
1297
  goto st0;
1273
- goto tr41;
1274
- tr41:
1275
- #line 328 "pitchfork_http.rl"
1298
+ goto tr42;
1299
+ tr42:
1300
+ #line 353 "pitchfork_http.rl"
1276
1301
  {MARK(mark, p); }
1277
1302
  goto st23;
1278
1303
  st23:
1279
1304
  if ( ++p == pe )
1280
1305
  goto _test_eof23;
1281
1306
  case 23:
1282
- #line 1283 "pitchfork_http.c"
1307
+ #line 1308 "pitchfork_http.c"
1283
1308
  switch( (*p) ) {
1284
- case 32: goto tr45;
1309
+ case 32: goto tr44;
1285
1310
  case 35: goto st0;
1286
1311
  case 37: goto st24;
1287
1312
  case 127: goto st0;
1288
1313
  }
1289
- if ( 0 <= (*p) && (*p) <= 31 )
1314
+ if ( (*p) <= 31 )
1290
1315
  goto st0;
1291
1316
  goto st23;
1292
1317
  tr43:
1293
- #line 328 "pitchfork_http.rl"
1318
+ #line 353 "pitchfork_http.rl"
1294
1319
  {MARK(mark, p); }
1295
1320
  goto st24;
1296
1321
  st24:
1297
1322
  if ( ++p == pe )
1298
1323
  goto _test_eof24;
1299
1324
  case 24:
1300
- #line 1301 "pitchfork_http.c"
1325
+ #line 1326 "pitchfork_http.c"
1301
1326
  if ( (*p) < 65 ) {
1302
1327
  if ( 48 <= (*p) && (*p) <= 57 )
1303
1328
  goto st25;
@@ -1321,28 +1346,28 @@ case 25:
1321
1346
  goto st23;
1322
1347
  goto st0;
1323
1348
  tr6:
1324
- #line 328 "pitchfork_http.rl"
1349
+ #line 353 "pitchfork_http.rl"
1325
1350
  {MARK(mark, p); }
1326
1351
  goto st26;
1327
1352
  tr76:
1328
- #line 341 "pitchfork_http.rl"
1353
+ #line 366 "pitchfork_http.rl"
1329
1354
  { rb_hash_aset(hp->env, g_http_host, STR_NEW(mark, p)); }
1330
- #line 328 "pitchfork_http.rl"
1355
+ #line 353 "pitchfork_http.rl"
1331
1356
  {MARK(mark, p); }
1332
1357
  goto st26;
1333
1358
  st26:
1334
1359
  if ( ++p == pe )
1335
1360
  goto _test_eof26;
1336
1361
  case 26:
1337
- #line 1338 "pitchfork_http.c"
1362
+ #line 1363 "pitchfork_http.c"
1338
1363
  switch( (*p) ) {
1339
- case 32: goto tr49;
1364
+ case 32: goto tr48;
1340
1365
  case 35: goto tr50;
1341
1366
  case 37: goto st27;
1342
1367
  case 63: goto tr52;
1343
1368
  case 127: goto st0;
1344
1369
  }
1345
- if ( 0 <= (*p) && (*p) <= 31 )
1370
+ if ( (*p) <= 31 )
1346
1371
  goto st0;
1347
1372
  goto st26;
1348
1373
  st27:
@@ -1372,7 +1397,7 @@ case 28:
1372
1397
  goto st26;
1373
1398
  goto st0;
1374
1399
  tr52:
1375
- #line 362 "pitchfork_http.rl"
1400
+ #line 387 "pitchfork_http.rl"
1376
1401
  {
1377
1402
  VALUE val;
1378
1403
 
@@ -1386,43 +1411,43 @@ st29:
1386
1411
  if ( ++p == pe )
1387
1412
  goto _test_eof29;
1388
1413
  case 29:
1389
- #line 1390 "pitchfork_http.c"
1414
+ #line 1415 "pitchfork_http.c"
1390
1415
  switch( (*p) ) {
1391
- case 32: goto tr55;
1416
+ case 32: goto tr54;
1392
1417
  case 35: goto tr56;
1393
1418
  case 37: goto tr57;
1394
1419
  case 127: goto st0;
1395
1420
  }
1396
- if ( 0 <= (*p) && (*p) <= 31 )
1421
+ if ( (*p) <= 31 )
1397
1422
  goto st0;
1398
- goto tr54;
1399
- tr54:
1400
- #line 356 "pitchfork_http.rl"
1423
+ goto tr55;
1424
+ tr55:
1425
+ #line 381 "pitchfork_http.rl"
1401
1426
  {MARK(start.query, p); }
1402
1427
  goto st30;
1403
1428
  st30:
1404
1429
  if ( ++p == pe )
1405
1430
  goto _test_eof30;
1406
1431
  case 30:
1407
- #line 1408 "pitchfork_http.c"
1432
+ #line 1433 "pitchfork_http.c"
1408
1433
  switch( (*p) ) {
1409
- case 32: goto tr59;
1434
+ case 32: goto tr58;
1410
1435
  case 35: goto tr60;
1411
1436
  case 37: goto st31;
1412
1437
  case 127: goto st0;
1413
1438
  }
1414
- if ( 0 <= (*p) && (*p) <= 31 )
1439
+ if ( (*p) <= 31 )
1415
1440
  goto st0;
1416
1441
  goto st30;
1417
1442
  tr57:
1418
- #line 356 "pitchfork_http.rl"
1443
+ #line 381 "pitchfork_http.rl"
1419
1444
  {MARK(start.query, p); }
1420
1445
  goto st31;
1421
1446
  st31:
1422
1447
  if ( ++p == pe )
1423
1448
  goto _test_eof31;
1424
1449
  case 31:
1425
- #line 1426 "pitchfork_http.c"
1450
+ #line 1451 "pitchfork_http.c"
1426
1451
  if ( (*p) < 65 ) {
1427
1452
  if ( 48 <= (*p) && (*p) <= 57 )
1428
1453
  goto st32;
@@ -1446,58 +1471,58 @@ case 32:
1446
1471
  goto st30;
1447
1472
  goto st0;
1448
1473
  tr7:
1449
- #line 328 "pitchfork_http.rl"
1474
+ #line 353 "pitchfork_http.rl"
1450
1475
  {MARK(mark, p); }
1451
- #line 332 "pitchfork_http.rl"
1476
+ #line 357 "pitchfork_http.rl"
1452
1477
  { downcase_char(deconst(p)); }
1453
1478
  goto st33;
1454
1479
  st33:
1455
1480
  if ( ++p == pe )
1456
1481
  goto _test_eof33;
1457
1482
  case 33:
1458
- #line 1459 "pitchfork_http.c"
1483
+ #line 1484 "pitchfork_http.c"
1459
1484
  switch( (*p) ) {
1460
1485
  case 84: goto tr63;
1461
1486
  case 116: goto tr63;
1462
1487
  }
1463
1488
  goto st0;
1464
1489
  tr63:
1465
- #line 332 "pitchfork_http.rl"
1490
+ #line 357 "pitchfork_http.rl"
1466
1491
  { downcase_char(deconst(p)); }
1467
1492
  goto st34;
1468
1493
  st34:
1469
1494
  if ( ++p == pe )
1470
1495
  goto _test_eof34;
1471
1496
  case 34:
1472
- #line 1473 "pitchfork_http.c"
1497
+ #line 1498 "pitchfork_http.c"
1473
1498
  switch( (*p) ) {
1474
1499
  case 84: goto tr64;
1475
1500
  case 116: goto tr64;
1476
1501
  }
1477
1502
  goto st0;
1478
1503
  tr64:
1479
- #line 332 "pitchfork_http.rl"
1504
+ #line 357 "pitchfork_http.rl"
1480
1505
  { downcase_char(deconst(p)); }
1481
1506
  goto st35;
1482
1507
  st35:
1483
1508
  if ( ++p == pe )
1484
1509
  goto _test_eof35;
1485
1510
  case 35:
1486
- #line 1487 "pitchfork_http.c"
1511
+ #line 1512 "pitchfork_http.c"
1487
1512
  switch( (*p) ) {
1488
1513
  case 80: goto tr65;
1489
1514
  case 112: goto tr65;
1490
1515
  }
1491
1516
  goto st0;
1492
1517
  tr65:
1493
- #line 332 "pitchfork_http.rl"
1518
+ #line 357 "pitchfork_http.rl"
1494
1519
  { downcase_char(deconst(p)); }
1495
1520
  goto st36;
1496
1521
  st36:
1497
1522
  if ( ++p == pe )
1498
1523
  goto _test_eof36;
1499
1524
  case 36:
1500
- #line 1501 "pitchfork_http.c"
1525
+ #line 1526 "pitchfork_http.c"
1501
1526
  switch( (*p) ) {
1502
1527
  case 58: goto tr66;
1503
1528
  case 83: goto tr67;
@@ -1505,7 +1530,7 @@ case 36:
1505
1530
  }
1506
1531
  goto st0;
1507
1532
  tr66:
1508
- #line 338 "pitchfork_http.rl"
1533
+ #line 363 "pitchfork_http.rl"
1509
1534
  {
1510
1535
  rb_hash_aset(hp->env, g_rack_url_scheme, STR_NEW(mark, p));
1511
1536
  }
@@ -1514,7 +1539,7 @@ st37:
1514
1539
  if ( ++p == pe )
1515
1540
  goto _test_eof37;
1516
1541
  case 37:
1517
- #line 1518 "pitchfork_http.c"
1542
+ #line 1543 "pitchfork_http.c"
1518
1543
  if ( (*p) == 47 )
1519
1544
  goto st38;
1520
1545
  goto st0;
@@ -1541,7 +1566,7 @@ case 39:
1541
1566
  if ( (*p) > 32 ) {
1542
1567
  if ( 34 <= (*p) && (*p) <= 35 )
1543
1568
  goto st0;
1544
- } else if ( (*p) >= 0 )
1569
+ } else
1545
1570
  goto st0;
1546
1571
  } else if ( (*p) > 57 ) {
1547
1572
  if ( (*p) < 65 ) {
@@ -1567,7 +1592,7 @@ case 40:
1567
1592
  case 127: goto st0;
1568
1593
  }
1569
1594
  if ( (*p) < 34 ) {
1570
- if ( 0 <= (*p) && (*p) <= 32 )
1595
+ if ( (*p) <= 32 )
1571
1596
  goto st0;
1572
1597
  } else if ( (*p) > 35 ) {
1573
1598
  if ( 62 <= (*p) && (*p) <= 63 )
@@ -1602,14 +1627,14 @@ case 42:
1602
1627
  goto st40;
1603
1628
  goto st0;
1604
1629
  tr72:
1605
- #line 328 "pitchfork_http.rl"
1630
+ #line 353 "pitchfork_http.rl"
1606
1631
  {MARK(mark, p); }
1607
1632
  goto st43;
1608
1633
  st43:
1609
1634
  if ( ++p == pe )
1610
1635
  goto _test_eof43;
1611
1636
  case 43:
1612
- #line 1613 "pitchfork_http.c"
1637
+ #line 1638 "pitchfork_http.c"
1613
1638
  switch( (*p) ) {
1614
1639
  case 37: goto st41;
1615
1640
  case 47: goto tr76;
@@ -1623,7 +1648,7 @@ case 43:
1623
1648
  if ( (*p) > 32 ) {
1624
1649
  if ( 34 <= (*p) && (*p) <= 35 )
1625
1650
  goto st0;
1626
- } else if ( (*p) >= 0 )
1651
+ } else
1627
1652
  goto st0;
1628
1653
  } else if ( (*p) > 57 ) {
1629
1654
  if ( (*p) < 65 ) {
@@ -1649,7 +1674,7 @@ case 44:
1649
1674
  case 127: goto st0;
1650
1675
  }
1651
1676
  if ( (*p) < 34 ) {
1652
- if ( 0 <= (*p) && (*p) <= 32 )
1677
+ if ( (*p) <= 32 )
1653
1678
  goto st0;
1654
1679
  } else if ( (*p) > 35 ) {
1655
1680
  if ( (*p) > 57 ) {
@@ -1661,14 +1686,14 @@ case 44:
1661
1686
  goto st0;
1662
1687
  goto st40;
1663
1688
  tr73:
1664
- #line 328 "pitchfork_http.rl"
1689
+ #line 353 "pitchfork_http.rl"
1665
1690
  {MARK(mark, p); }
1666
1691
  goto st45;
1667
1692
  st45:
1668
1693
  if ( ++p == pe )
1669
1694
  goto _test_eof45;
1670
1695
  case 45:
1671
- #line 1672 "pitchfork_http.c"
1696
+ #line 1697 "pitchfork_http.c"
1672
1697
  switch( (*p) ) {
1673
1698
  case 37: goto st41;
1674
1699
  case 47: goto st0;
@@ -1680,7 +1705,7 @@ case 45:
1680
1705
  if ( (*p) > 32 ) {
1681
1706
  if ( 34 <= (*p) && (*p) <= 35 )
1682
1707
  goto st0;
1683
- } else if ( (*p) >= 0 )
1708
+ } else
1684
1709
  goto st0;
1685
1710
  } else if ( (*p) > 58 ) {
1686
1711
  if ( (*p) < 65 ) {
@@ -1710,7 +1735,7 @@ case 46:
1710
1735
  if ( (*p) > 32 ) {
1711
1736
  if ( 34 <= (*p) && (*p) <= 35 )
1712
1737
  goto st0;
1713
- } else if ( (*p) >= 0 )
1738
+ } else
1714
1739
  goto st0;
1715
1740
  } else if ( (*p) > 58 ) {
1716
1741
  if ( (*p) < 65 ) {
@@ -1737,7 +1762,7 @@ case 47:
1737
1762
  case 127: goto st0;
1738
1763
  }
1739
1764
  if ( (*p) < 34 ) {
1740
- if ( 0 <= (*p) && (*p) <= 32 )
1765
+ if ( (*p) <= 32 )
1741
1766
  goto st0;
1742
1767
  } else if ( (*p) > 35 ) {
1743
1768
  if ( 62 <= (*p) && (*p) <= 63 )
@@ -1746,14 +1771,14 @@ case 47:
1746
1771
  goto st0;
1747
1772
  goto st40;
1748
1773
  tr67:
1749
- #line 332 "pitchfork_http.rl"
1774
+ #line 357 "pitchfork_http.rl"
1750
1775
  { downcase_char(deconst(p)); }
1751
1776
  goto st48;
1752
1777
  st48:
1753
1778
  if ( ++p == pe )
1754
1779
  goto _test_eof48;
1755
1780
  case 48:
1756
- #line 1757 "pitchfork_http.c"
1781
+ #line 1782 "pitchfork_http.c"
1757
1782
  if ( (*p) == 58 )
1758
1783
  goto tr66;
1759
1784
  goto st0;
@@ -2269,14 +2294,14 @@ case 67:
2269
2294
  goto tr3;
2270
2295
  goto st0;
2271
2296
  tr2:
2272
- #line 328 "pitchfork_http.rl"
2297
+ #line 353 "pitchfork_http.rl"
2273
2298
  {MARK(mark, p); }
2274
2299
  goto st68;
2275
2300
  st68:
2276
2301
  if ( ++p == pe )
2277
2302
  goto _test_eof68;
2278
2303
  case 68:
2279
- #line 2280 "pitchfork_http.c"
2304
+ #line 2305 "pitchfork_http.c"
2280
2305
  switch( (*p) ) {
2281
2306
  case 32: goto tr3;
2282
2307
  case 33: goto st49;
@@ -2360,14 +2385,14 @@ case 70:
2360
2385
  goto st51;
2361
2386
  goto st0;
2362
2387
  tr100:
2363
- #line 337 "pitchfork_http.rl"
2388
+ #line 362 "pitchfork_http.rl"
2364
2389
  { request_method(hp, PTR_TO(mark), LEN(mark, p)); }
2365
2390
  goto st71;
2366
2391
  st71:
2367
2392
  if ( ++p == pe )
2368
2393
  goto _test_eof71;
2369
2394
  case 71:
2370
- #line 2371 "pitchfork_http.c"
2395
+ #line 2396 "pitchfork_http.c"
2371
2396
  switch( (*p) ) {
2372
2397
  case 42: goto tr101;
2373
2398
  case 47: goto tr102;
@@ -2376,14 +2401,14 @@ case 71:
2376
2401
  }
2377
2402
  goto st0;
2378
2403
  tr101:
2379
- #line 328 "pitchfork_http.rl"
2404
+ #line 353 "pitchfork_http.rl"
2380
2405
  {MARK(mark, p); }
2381
2406
  goto st72;
2382
2407
  st72:
2383
2408
  if ( ++p == pe )
2384
2409
  goto _test_eof72;
2385
2410
  case 72:
2386
- #line 2387 "pitchfork_http.c"
2411
+ #line 2412 "pitchfork_http.c"
2387
2412
  switch( (*p) ) {
2388
2413
  case 10: goto tr104;
2389
2414
  case 13: goto tr105;
@@ -2392,7 +2417,7 @@ case 72:
2392
2417
  }
2393
2418
  goto st0;
2394
2419
  tr106:
2395
- #line 342 "pitchfork_http.rl"
2420
+ #line 367 "pitchfork_http.rl"
2396
2421
  {
2397
2422
  VALUE str;
2398
2423
 
@@ -2405,7 +2430,7 @@ tr106:
2405
2430
  }
2406
2431
  goto st73;
2407
2432
  tr119:
2408
- #line 362 "pitchfork_http.rl"
2433
+ #line 387 "pitchfork_http.rl"
2409
2434
  {
2410
2435
  VALUE val;
2411
2436
 
@@ -2414,7 +2439,7 @@ tr119:
2414
2439
 
2415
2440
  rb_hash_aset(hp->env, g_path_info, val);
2416
2441
  }
2417
- #line 342 "pitchfork_http.rl"
2442
+ #line 367 "pitchfork_http.rl"
2418
2443
  {
2419
2444
  VALUE str;
2420
2445
 
@@ -2427,14 +2452,14 @@ tr119:
2427
2452
  }
2428
2453
  goto st73;
2429
2454
  tr126:
2430
- #line 356 "pitchfork_http.rl"
2455
+ #line 381 "pitchfork_http.rl"
2431
2456
  {MARK(start.query, p); }
2432
- #line 357 "pitchfork_http.rl"
2457
+ #line 382 "pitchfork_http.rl"
2433
2458
  {
2434
2459
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
2435
2460
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
2436
2461
  }
2437
- #line 342 "pitchfork_http.rl"
2462
+ #line 367 "pitchfork_http.rl"
2438
2463
  {
2439
2464
  VALUE str;
2440
2465
 
@@ -2447,12 +2472,12 @@ tr126:
2447
2472
  }
2448
2473
  goto st73;
2449
2474
  tr131:
2450
- #line 357 "pitchfork_http.rl"
2475
+ #line 382 "pitchfork_http.rl"
2451
2476
  {
2452
2477
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
2453
2478
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
2454
2479
  }
2455
- #line 342 "pitchfork_http.rl"
2480
+ #line 367 "pitchfork_http.rl"
2456
2481
  {
2457
2482
  VALUE str;
2458
2483
 
@@ -2468,47 +2493,47 @@ st73:
2468
2493
  if ( ++p == pe )
2469
2494
  goto _test_eof73;
2470
2495
  case 73:
2471
- #line 2472 "pitchfork_http.c"
2496
+ #line 2497 "pitchfork_http.c"
2472
2497
  switch( (*p) ) {
2473
- case 10: goto tr108;
2474
- case 13: goto tr109;
2475
- case 32: goto tr42;
2498
+ case 10: goto tr107;
2499
+ case 13: goto tr108;
2500
+ case 32: goto tr41;
2476
2501
  case 35: goto st0;
2477
2502
  case 37: goto tr110;
2478
2503
  case 127: goto st0;
2479
2504
  }
2480
- if ( 0 <= (*p) && (*p) <= 31 )
2505
+ if ( (*p) <= 31 )
2481
2506
  goto st0;
2482
- goto tr107;
2483
- tr107:
2484
- #line 328 "pitchfork_http.rl"
2507
+ goto tr109;
2508
+ tr109:
2509
+ #line 353 "pitchfork_http.rl"
2485
2510
  {MARK(mark, p); }
2486
2511
  goto st74;
2487
2512
  st74:
2488
2513
  if ( ++p == pe )
2489
2514
  goto _test_eof74;
2490
2515
  case 74:
2491
- #line 2492 "pitchfork_http.c"
2516
+ #line 2517 "pitchfork_http.c"
2492
2517
  switch( (*p) ) {
2493
- case 10: goto tr112;
2494
- case 13: goto tr113;
2495
- case 32: goto tr45;
2518
+ case 10: goto tr111;
2519
+ case 13: goto tr112;
2520
+ case 32: goto tr44;
2496
2521
  case 35: goto st0;
2497
2522
  case 37: goto st75;
2498
2523
  case 127: goto st0;
2499
2524
  }
2500
- if ( 0 <= (*p) && (*p) <= 31 )
2525
+ if ( (*p) <= 31 )
2501
2526
  goto st0;
2502
2527
  goto st74;
2503
2528
  tr110:
2504
- #line 328 "pitchfork_http.rl"
2529
+ #line 353 "pitchfork_http.rl"
2505
2530
  {MARK(mark, p); }
2506
2531
  goto st75;
2507
2532
  st75:
2508
2533
  if ( ++p == pe )
2509
2534
  goto _test_eof75;
2510
2535
  case 75:
2511
- #line 2512 "pitchfork_http.c"
2536
+ #line 2537 "pitchfork_http.c"
2512
2537
  if ( (*p) < 65 ) {
2513
2538
  if ( 48 <= (*p) && (*p) <= 57 )
2514
2539
  goto st76;
@@ -2532,30 +2557,30 @@ case 76:
2532
2557
  goto st74;
2533
2558
  goto st0;
2534
2559
  tr102:
2535
- #line 328 "pitchfork_http.rl"
2560
+ #line 353 "pitchfork_http.rl"
2536
2561
  {MARK(mark, p); }
2537
2562
  goto st77;
2538
2563
  tr147:
2539
- #line 341 "pitchfork_http.rl"
2564
+ #line 366 "pitchfork_http.rl"
2540
2565
  { rb_hash_aset(hp->env, g_http_host, STR_NEW(mark, p)); }
2541
- #line 328 "pitchfork_http.rl"
2566
+ #line 353 "pitchfork_http.rl"
2542
2567
  {MARK(mark, p); }
2543
2568
  goto st77;
2544
2569
  st77:
2545
2570
  if ( ++p == pe )
2546
2571
  goto _test_eof77;
2547
2572
  case 77:
2548
- #line 2549 "pitchfork_http.c"
2573
+ #line 2574 "pitchfork_http.c"
2549
2574
  switch( (*p) ) {
2550
- case 10: goto tr117;
2551
- case 13: goto tr118;
2552
- case 32: goto tr49;
2575
+ case 10: goto tr116;
2576
+ case 13: goto tr117;
2577
+ case 32: goto tr48;
2553
2578
  case 35: goto tr119;
2554
2579
  case 37: goto st78;
2555
2580
  case 63: goto tr121;
2556
2581
  case 127: goto st0;
2557
2582
  }
2558
- if ( 0 <= (*p) && (*p) <= 31 )
2583
+ if ( (*p) <= 31 )
2559
2584
  goto st0;
2560
2585
  goto st77;
2561
2586
  st78:
@@ -2585,7 +2610,7 @@ case 79:
2585
2610
  goto st77;
2586
2611
  goto st0;
2587
2612
  tr121:
2588
- #line 362 "pitchfork_http.rl"
2613
+ #line 387 "pitchfork_http.rl"
2589
2614
  {
2590
2615
  VALUE val;
2591
2616
 
@@ -2599,47 +2624,47 @@ st80:
2599
2624
  if ( ++p == pe )
2600
2625
  goto _test_eof80;
2601
2626
  case 80:
2602
- #line 2603 "pitchfork_http.c"
2627
+ #line 2628 "pitchfork_http.c"
2603
2628
  switch( (*p) ) {
2604
- case 10: goto tr124;
2605
- case 13: goto tr125;
2606
- case 32: goto tr55;
2629
+ case 10: goto tr123;
2630
+ case 13: goto tr124;
2631
+ case 32: goto tr54;
2607
2632
  case 35: goto tr126;
2608
2633
  case 37: goto tr127;
2609
2634
  case 127: goto st0;
2610
2635
  }
2611
- if ( 0 <= (*p) && (*p) <= 31 )
2636
+ if ( (*p) <= 31 )
2612
2637
  goto st0;
2613
- goto tr123;
2614
- tr123:
2615
- #line 356 "pitchfork_http.rl"
2638
+ goto tr125;
2639
+ tr125:
2640
+ #line 381 "pitchfork_http.rl"
2616
2641
  {MARK(start.query, p); }
2617
2642
  goto st81;
2618
2643
  st81:
2619
2644
  if ( ++p == pe )
2620
2645
  goto _test_eof81;
2621
2646
  case 81:
2622
- #line 2623 "pitchfork_http.c"
2647
+ #line 2648 "pitchfork_http.c"
2623
2648
  switch( (*p) ) {
2624
- case 10: goto tr129;
2625
- case 13: goto tr130;
2626
- case 32: goto tr59;
2649
+ case 10: goto tr128;
2650
+ case 13: goto tr129;
2651
+ case 32: goto tr58;
2627
2652
  case 35: goto tr131;
2628
2653
  case 37: goto st82;
2629
2654
  case 127: goto st0;
2630
2655
  }
2631
- if ( 0 <= (*p) && (*p) <= 31 )
2656
+ if ( (*p) <= 31 )
2632
2657
  goto st0;
2633
2658
  goto st81;
2634
2659
  tr127:
2635
- #line 356 "pitchfork_http.rl"
2660
+ #line 381 "pitchfork_http.rl"
2636
2661
  {MARK(start.query, p); }
2637
2662
  goto st82;
2638
2663
  st82:
2639
2664
  if ( ++p == pe )
2640
2665
  goto _test_eof82;
2641
2666
  case 82:
2642
- #line 2643 "pitchfork_http.c"
2667
+ #line 2668 "pitchfork_http.c"
2643
2668
  if ( (*p) < 65 ) {
2644
2669
  if ( 48 <= (*p) && (*p) <= 57 )
2645
2670
  goto st83;
@@ -2663,58 +2688,58 @@ case 83:
2663
2688
  goto st81;
2664
2689
  goto st0;
2665
2690
  tr103:
2666
- #line 328 "pitchfork_http.rl"
2691
+ #line 353 "pitchfork_http.rl"
2667
2692
  {MARK(mark, p); }
2668
- #line 332 "pitchfork_http.rl"
2693
+ #line 357 "pitchfork_http.rl"
2669
2694
  { downcase_char(deconst(p)); }
2670
2695
  goto st84;
2671
2696
  st84:
2672
2697
  if ( ++p == pe )
2673
2698
  goto _test_eof84;
2674
2699
  case 84:
2675
- #line 2676 "pitchfork_http.c"
2700
+ #line 2701 "pitchfork_http.c"
2676
2701
  switch( (*p) ) {
2677
2702
  case 84: goto tr134;
2678
2703
  case 116: goto tr134;
2679
2704
  }
2680
2705
  goto st0;
2681
2706
  tr134:
2682
- #line 332 "pitchfork_http.rl"
2707
+ #line 357 "pitchfork_http.rl"
2683
2708
  { downcase_char(deconst(p)); }
2684
2709
  goto st85;
2685
2710
  st85:
2686
2711
  if ( ++p == pe )
2687
2712
  goto _test_eof85;
2688
2713
  case 85:
2689
- #line 2690 "pitchfork_http.c"
2714
+ #line 2715 "pitchfork_http.c"
2690
2715
  switch( (*p) ) {
2691
2716
  case 84: goto tr135;
2692
2717
  case 116: goto tr135;
2693
2718
  }
2694
2719
  goto st0;
2695
2720
  tr135:
2696
- #line 332 "pitchfork_http.rl"
2721
+ #line 357 "pitchfork_http.rl"
2697
2722
  { downcase_char(deconst(p)); }
2698
2723
  goto st86;
2699
2724
  st86:
2700
2725
  if ( ++p == pe )
2701
2726
  goto _test_eof86;
2702
2727
  case 86:
2703
- #line 2704 "pitchfork_http.c"
2728
+ #line 2729 "pitchfork_http.c"
2704
2729
  switch( (*p) ) {
2705
2730
  case 80: goto tr136;
2706
2731
  case 112: goto tr136;
2707
2732
  }
2708
2733
  goto st0;
2709
2734
  tr136:
2710
- #line 332 "pitchfork_http.rl"
2735
+ #line 357 "pitchfork_http.rl"
2711
2736
  { downcase_char(deconst(p)); }
2712
2737
  goto st87;
2713
2738
  st87:
2714
2739
  if ( ++p == pe )
2715
2740
  goto _test_eof87;
2716
2741
  case 87:
2717
- #line 2718 "pitchfork_http.c"
2742
+ #line 2743 "pitchfork_http.c"
2718
2743
  switch( (*p) ) {
2719
2744
  case 58: goto tr137;
2720
2745
  case 83: goto tr138;
@@ -2722,7 +2747,7 @@ case 87:
2722
2747
  }
2723
2748
  goto st0;
2724
2749
  tr137:
2725
- #line 338 "pitchfork_http.rl"
2750
+ #line 363 "pitchfork_http.rl"
2726
2751
  {
2727
2752
  rb_hash_aset(hp->env, g_rack_url_scheme, STR_NEW(mark, p));
2728
2753
  }
@@ -2731,7 +2756,7 @@ st88:
2731
2756
  if ( ++p == pe )
2732
2757
  goto _test_eof88;
2733
2758
  case 88:
2734
- #line 2735 "pitchfork_http.c"
2759
+ #line 2760 "pitchfork_http.c"
2735
2760
  if ( (*p) == 47 )
2736
2761
  goto st89;
2737
2762
  goto st0;
@@ -2758,7 +2783,7 @@ case 90:
2758
2783
  if ( (*p) > 32 ) {
2759
2784
  if ( 34 <= (*p) && (*p) <= 35 )
2760
2785
  goto st0;
2761
- } else if ( (*p) >= 0 )
2786
+ } else
2762
2787
  goto st0;
2763
2788
  } else if ( (*p) > 57 ) {
2764
2789
  if ( (*p) < 65 ) {
@@ -2784,7 +2809,7 @@ case 91:
2784
2809
  case 127: goto st0;
2785
2810
  }
2786
2811
  if ( (*p) < 34 ) {
2787
- if ( 0 <= (*p) && (*p) <= 32 )
2812
+ if ( (*p) <= 32 )
2788
2813
  goto st0;
2789
2814
  } else if ( (*p) > 35 ) {
2790
2815
  if ( 62 <= (*p) && (*p) <= 63 )
@@ -2819,14 +2844,14 @@ case 93:
2819
2844
  goto st91;
2820
2845
  goto st0;
2821
2846
  tr143:
2822
- #line 328 "pitchfork_http.rl"
2847
+ #line 353 "pitchfork_http.rl"
2823
2848
  {MARK(mark, p); }
2824
2849
  goto st94;
2825
2850
  st94:
2826
2851
  if ( ++p == pe )
2827
2852
  goto _test_eof94;
2828
2853
  case 94:
2829
- #line 2830 "pitchfork_http.c"
2854
+ #line 2855 "pitchfork_http.c"
2830
2855
  switch( (*p) ) {
2831
2856
  case 37: goto st92;
2832
2857
  case 47: goto tr147;
@@ -2840,7 +2865,7 @@ case 94:
2840
2865
  if ( (*p) > 32 ) {
2841
2866
  if ( 34 <= (*p) && (*p) <= 35 )
2842
2867
  goto st0;
2843
- } else if ( (*p) >= 0 )
2868
+ } else
2844
2869
  goto st0;
2845
2870
  } else if ( (*p) > 57 ) {
2846
2871
  if ( (*p) < 65 ) {
@@ -2866,7 +2891,7 @@ case 95:
2866
2891
  case 127: goto st0;
2867
2892
  }
2868
2893
  if ( (*p) < 34 ) {
2869
- if ( 0 <= (*p) && (*p) <= 32 )
2894
+ if ( (*p) <= 32 )
2870
2895
  goto st0;
2871
2896
  } else if ( (*p) > 35 ) {
2872
2897
  if ( (*p) > 57 ) {
@@ -2878,14 +2903,14 @@ case 95:
2878
2903
  goto st0;
2879
2904
  goto st91;
2880
2905
  tr144:
2881
- #line 328 "pitchfork_http.rl"
2906
+ #line 353 "pitchfork_http.rl"
2882
2907
  {MARK(mark, p); }
2883
2908
  goto st96;
2884
2909
  st96:
2885
2910
  if ( ++p == pe )
2886
2911
  goto _test_eof96;
2887
2912
  case 96:
2888
- #line 2889 "pitchfork_http.c"
2913
+ #line 2914 "pitchfork_http.c"
2889
2914
  switch( (*p) ) {
2890
2915
  case 37: goto st92;
2891
2916
  case 47: goto st0;
@@ -2897,7 +2922,7 @@ case 96:
2897
2922
  if ( (*p) > 32 ) {
2898
2923
  if ( 34 <= (*p) && (*p) <= 35 )
2899
2924
  goto st0;
2900
- } else if ( (*p) >= 0 )
2925
+ } else
2901
2926
  goto st0;
2902
2927
  } else if ( (*p) > 58 ) {
2903
2928
  if ( (*p) < 65 ) {
@@ -2927,7 +2952,7 @@ case 97:
2927
2952
  if ( (*p) > 32 ) {
2928
2953
  if ( 34 <= (*p) && (*p) <= 35 )
2929
2954
  goto st0;
2930
- } else if ( (*p) >= 0 )
2955
+ } else
2931
2956
  goto st0;
2932
2957
  } else if ( (*p) > 58 ) {
2933
2958
  if ( (*p) < 65 ) {
@@ -2954,7 +2979,7 @@ case 98:
2954
2979
  case 127: goto st0;
2955
2980
  }
2956
2981
  if ( (*p) < 34 ) {
2957
- if ( 0 <= (*p) && (*p) <= 32 )
2982
+ if ( (*p) <= 32 )
2958
2983
  goto st0;
2959
2984
  } else if ( (*p) > 35 ) {
2960
2985
  if ( 62 <= (*p) && (*p) <= 63 )
@@ -2963,14 +2988,14 @@ case 98:
2963
2988
  goto st0;
2964
2989
  goto st91;
2965
2990
  tr138:
2966
- #line 332 "pitchfork_http.rl"
2991
+ #line 357 "pitchfork_http.rl"
2967
2992
  { downcase_char(deconst(p)); }
2968
2993
  goto st99;
2969
2994
  st99:
2970
2995
  if ( ++p == pe )
2971
2996
  goto _test_eof99;
2972
2997
  case 99:
2973
- #line 2974 "pitchfork_http.c"
2998
+ #line 2999 "pitchfork_http.c"
2974
2999
  if ( (*p) == 58 )
2975
3000
  goto tr137;
2976
3001
  goto st0;
@@ -2990,7 +3015,7 @@ case 100:
2990
3015
  goto tr152;
2991
3016
  goto st0;
2992
3017
  tr151:
2993
- #line 370 "pitchfork_http.rl"
3018
+ #line 395 "pitchfork_http.rl"
2994
3019
  {
2995
3020
  hp->len.chunk = step_incr(hp->len.chunk, (*p), 16);
2996
3021
  if (hp->len.chunk < 0)
@@ -3001,7 +3026,7 @@ st101:
3001
3026
  if ( ++p == pe )
3002
3027
  goto _test_eof101;
3003
3028
  case 101:
3004
- #line 3005 "pitchfork_http.c"
3029
+ #line 3030 "pitchfork_http.c"
3005
3030
  switch( (*p) ) {
3006
3031
  case 10: goto tr153;
3007
3032
  case 13: goto st102;
@@ -3018,9 +3043,10 @@ case 101:
3018
3043
  goto tr152;
3019
3044
  goto st0;
3020
3045
  tr153:
3021
- #line 399 "pitchfork_http.rl"
3046
+ #line 424 "pitchfork_http.rl"
3022
3047
  {
3023
3048
  HP_FL_SET(hp, INTRAILER);
3049
+ RB_OBJ_WRITE(self, &hp->cont, Qfalse);
3024
3050
  cs = http_parser_en_Trailers;
3025
3051
  ++p;
3026
3052
  assert(p <= pe && "buffer overflow after chunked body");
@@ -3031,7 +3057,7 @@ st123:
3031
3057
  if ( ++p == pe )
3032
3058
  goto _test_eof123;
3033
3059
  case 123:
3034
- #line 3035 "pitchfork_http.c"
3060
+ #line 3061 "pitchfork_http.c"
3035
3061
  goto st0;
3036
3062
  st102:
3037
3063
  if ( ++p == pe )
@@ -3041,7 +3067,7 @@ case 102:
3041
3067
  goto tr153;
3042
3068
  goto st0;
3043
3069
  tr152:
3044
- #line 370 "pitchfork_http.rl"
3070
+ #line 395 "pitchfork_http.rl"
3045
3071
  {
3046
3072
  hp->len.chunk = step_incr(hp->len.chunk, (*p), 16);
3047
3073
  if (hp->len.chunk < 0)
@@ -3052,7 +3078,7 @@ st103:
3052
3078
  if ( ++p == pe )
3053
3079
  goto _test_eof103;
3054
3080
  case 103:
3055
- #line 3056 "pitchfork_http.c"
3081
+ #line 3082 "pitchfork_http.c"
3056
3082
  switch( (*p) ) {
3057
3083
  case 10: goto st104;
3058
3084
  case 13: goto st107;
@@ -3073,7 +3099,7 @@ st104:
3073
3099
  case 104:
3074
3100
  goto tr159;
3075
3101
  tr159:
3076
- #line 407 "pitchfork_http.rl"
3102
+ #line 433 "pitchfork_http.rl"
3077
3103
  {
3078
3104
  skip_chunk_data_hack: {
3079
3105
  size_t nr = MIN((size_t)hp->len.chunk, REMAINING);
@@ -3095,7 +3121,7 @@ st105:
3095
3121
  if ( ++p == pe )
3096
3122
  goto _test_eof105;
3097
3123
  case 105:
3098
- #line 3099 "pitchfork_http.c"
3124
+ #line 3125 "pitchfork_http.c"
3099
3125
  switch( (*p) ) {
3100
3126
  case 10: goto st100;
3101
3127
  case 13: goto st106;
@@ -3301,31 +3327,31 @@ case 113:
3301
3327
  } else
3302
3328
  goto st113;
3303
3329
  goto st0;
3304
- tr172:
3305
- #line 334 "pitchfork_http.rl"
3330
+ tr171:
3331
+ #line 359 "pitchfork_http.rl"
3306
3332
  { MARK(mark, p); }
3307
- #line 336 "pitchfork_http.rl"
3333
+ #line 361 "pitchfork_http.rl"
3308
3334
  { write_cont_value(hp, buffer, p); }
3309
3335
  goto st114;
3310
- tr175:
3311
- #line 336 "pitchfork_http.rl"
3336
+ tr176:
3337
+ #line 361 "pitchfork_http.rl"
3312
3338
  { write_cont_value(hp, buffer, p); }
3313
3339
  goto st114;
3314
- tr182:
3315
- #line 334 "pitchfork_http.rl"
3340
+ tr181:
3341
+ #line 359 "pitchfork_http.rl"
3316
3342
  { MARK(mark, p); }
3317
- #line 335 "pitchfork_http.rl"
3343
+ #line 360 "pitchfork_http.rl"
3318
3344
  { write_value(self, hp, buffer, p); }
3319
3345
  goto st114;
3320
3346
  tr185:
3321
- #line 335 "pitchfork_http.rl"
3347
+ #line 360 "pitchfork_http.rl"
3322
3348
  { write_value(self, hp, buffer, p); }
3323
3349
  goto st114;
3324
3350
  st114:
3325
3351
  if ( ++p == pe )
3326
3352
  goto _test_eof114;
3327
3353
  case 114:
3328
- #line 3329 "pitchfork_http.c"
3354
+ #line 3355 "pitchfork_http.c"
3329
3355
  switch( (*p) ) {
3330
3356
  case 9: goto st115;
3331
3357
  case 10: goto tr167;
@@ -3353,75 +3379,75 @@ case 114:
3353
3379
  } else
3354
3380
  goto tr169;
3355
3381
  goto st0;
3356
- tr171:
3357
- #line 334 "pitchfork_http.rl"
3382
+ tr170:
3383
+ #line 359 "pitchfork_http.rl"
3358
3384
  { MARK(mark, p); }
3359
3385
  goto st115;
3360
3386
  st115:
3361
3387
  if ( ++p == pe )
3362
3388
  goto _test_eof115;
3363
3389
  case 115:
3364
- #line 3365 "pitchfork_http.c"
3390
+ #line 3391 "pitchfork_http.c"
3365
3391
  switch( (*p) ) {
3366
- case 9: goto tr171;
3367
- case 10: goto tr172;
3368
- case 13: goto tr173;
3369
- case 32: goto tr171;
3392
+ case 9: goto tr170;
3393
+ case 10: goto tr171;
3394
+ case 13: goto tr172;
3395
+ case 32: goto tr170;
3370
3396
  case 127: goto st0;
3371
3397
  }
3372
- if ( 0 <= (*p) && (*p) <= 31 )
3398
+ if ( (*p) <= 31 )
3373
3399
  goto st0;
3374
- goto tr170;
3375
- tr170:
3376
- #line 334 "pitchfork_http.rl"
3400
+ goto tr173;
3401
+ tr172:
3402
+ #line 359 "pitchfork_http.rl"
3403
+ { MARK(mark, p); }
3404
+ #line 361 "pitchfork_http.rl"
3405
+ { write_cont_value(hp, buffer, p); }
3406
+ goto st116;
3407
+ tr177:
3408
+ #line 361 "pitchfork_http.rl"
3409
+ { write_cont_value(hp, buffer, p); }
3410
+ goto st116;
3411
+ tr182:
3412
+ #line 359 "pitchfork_http.rl"
3377
3413
  { MARK(mark, p); }
3414
+ #line 360 "pitchfork_http.rl"
3415
+ { write_value(self, hp, buffer, p); }
3416
+ goto st116;
3417
+ tr186:
3418
+ #line 360 "pitchfork_http.rl"
3419
+ { write_value(self, hp, buffer, p); }
3378
3420
  goto st116;
3379
3421
  st116:
3380
3422
  if ( ++p == pe )
3381
3423
  goto _test_eof116;
3382
3424
  case 116:
3383
- #line 3384 "pitchfork_http.c"
3425
+ #line 3426 "pitchfork_http.c"
3426
+ if ( (*p) == 10 )
3427
+ goto st114;
3428
+ goto st0;
3429
+ tr173:
3430
+ #line 359 "pitchfork_http.rl"
3431
+ { MARK(mark, p); }
3432
+ goto st117;
3433
+ st117:
3434
+ if ( ++p == pe )
3435
+ goto _test_eof117;
3436
+ case 117:
3437
+ #line 3438 "pitchfork_http.c"
3384
3438
  switch( (*p) ) {
3385
- case 10: goto tr175;
3386
- case 13: goto tr176;
3439
+ case 10: goto tr176;
3440
+ case 13: goto tr177;
3387
3441
  case 127: goto st0;
3388
3442
  }
3389
3443
  if ( (*p) > 8 ) {
3390
3444
  if ( 11 <= (*p) && (*p) <= 31 )
3391
3445
  goto st0;
3392
- } else if ( (*p) >= 0 )
3446
+ } else
3393
3447
  goto st0;
3394
- goto st116;
3395
- tr173:
3396
- #line 334 "pitchfork_http.rl"
3397
- { MARK(mark, p); }
3398
- #line 336 "pitchfork_http.rl"
3399
- { write_cont_value(hp, buffer, p); }
3400
3448
  goto st117;
3401
- tr176:
3402
- #line 336 "pitchfork_http.rl"
3403
- { write_cont_value(hp, buffer, p); }
3404
- goto st117;
3405
- tr183:
3406
- #line 334 "pitchfork_http.rl"
3407
- { MARK(mark, p); }
3408
- #line 335 "pitchfork_http.rl"
3409
- { write_value(self, hp, buffer, p); }
3410
- goto st117;
3411
- tr186:
3412
- #line 335 "pitchfork_http.rl"
3413
- { write_value(self, hp, buffer, p); }
3414
- goto st117;
3415
- st117:
3416
- if ( ++p == pe )
3417
- goto _test_eof117;
3418
- case 117:
3419
- #line 3420 "pitchfork_http.c"
3420
- if ( (*p) == 10 )
3421
- goto st114;
3422
- goto st0;
3423
3449
  tr167:
3424
- #line 394 "pitchfork_http.rl"
3450
+ #line 419 "pitchfork_http.rl"
3425
3451
  {
3426
3452
  cs = http_parser_first_final;
3427
3453
  goto post_exec;
@@ -3431,7 +3457,7 @@ st124:
3431
3457
  if ( ++p == pe )
3432
3458
  goto _test_eof124;
3433
3459
  case 124:
3434
- #line 3435 "pitchfork_http.c"
3460
+ #line 3461 "pitchfork_http.c"
3435
3461
  goto st0;
3436
3462
  st118:
3437
3463
  if ( ++p == pe )
@@ -3441,20 +3467,20 @@ case 118:
3441
3467
  goto tr167;
3442
3468
  goto st0;
3443
3469
  tr169:
3444
- #line 330 "pitchfork_http.rl"
3470
+ #line 355 "pitchfork_http.rl"
3445
3471
  { MARK(start.field, p); }
3446
- #line 331 "pitchfork_http.rl"
3447
- { snake_upcase_char(deconst(p)); }
3472
+ #line 356 "pitchfork_http.rl"
3473
+ { upcase_char(deconst(p)); }
3448
3474
  goto st119;
3449
3475
  tr178:
3450
- #line 331 "pitchfork_http.rl"
3451
- { snake_upcase_char(deconst(p)); }
3476
+ #line 356 "pitchfork_http.rl"
3477
+ { upcase_char(deconst(p)); }
3452
3478
  goto st119;
3453
3479
  st119:
3454
3480
  if ( ++p == pe )
3455
3481
  goto _test_eof119;
3456
3482
  case 119:
3457
- #line 3458 "pitchfork_http.c"
3483
+ #line 3484 "pitchfork_http.c"
3458
3484
  switch( (*p) ) {
3459
3485
  case 33: goto tr178;
3460
3486
  case 58: goto tr179;
@@ -3479,38 +3505,38 @@ case 119:
3479
3505
  } else
3480
3506
  goto tr178;
3481
3507
  goto st0;
3482
- tr181:
3483
- #line 334 "pitchfork_http.rl"
3508
+ tr180:
3509
+ #line 359 "pitchfork_http.rl"
3484
3510
  { MARK(mark, p); }
3485
3511
  goto st120;
3486
3512
  tr179:
3487
- #line 333 "pitchfork_http.rl"
3513
+ #line 358 "pitchfork_http.rl"
3488
3514
  { hp->s.field_len = LEN(start.field, p); }
3489
3515
  goto st120;
3490
3516
  st120:
3491
3517
  if ( ++p == pe )
3492
3518
  goto _test_eof120;
3493
3519
  case 120:
3494
- #line 3495 "pitchfork_http.c"
3520
+ #line 3521 "pitchfork_http.c"
3495
3521
  switch( (*p) ) {
3496
- case 9: goto tr181;
3497
- case 10: goto tr182;
3498
- case 13: goto tr183;
3499
- case 32: goto tr181;
3522
+ case 9: goto tr180;
3523
+ case 10: goto tr181;
3524
+ case 13: goto tr182;
3525
+ case 32: goto tr180;
3500
3526
  case 127: goto st0;
3501
3527
  }
3502
- if ( 0 <= (*p) && (*p) <= 31 )
3528
+ if ( (*p) <= 31 )
3503
3529
  goto st0;
3504
- goto tr180;
3505
- tr180:
3506
- #line 334 "pitchfork_http.rl"
3530
+ goto tr183;
3531
+ tr183:
3532
+ #line 359 "pitchfork_http.rl"
3507
3533
  { MARK(mark, p); }
3508
3534
  goto st121;
3509
3535
  st121:
3510
3536
  if ( ++p == pe )
3511
3537
  goto _test_eof121;
3512
3538
  case 121:
3513
- #line 3514 "pitchfork_http.c"
3539
+ #line 3540 "pitchfork_http.c"
3514
3540
  switch( (*p) ) {
3515
3541
  case 10: goto tr185;
3516
3542
  case 13: goto tr186;
@@ -3519,7 +3545,7 @@ case 121:
3519
3545
  if ( (*p) > 8 ) {
3520
3546
  if ( 11 <= (*p) && (*p) <= 31 )
3521
3547
  goto st0;
3522
- } else if ( (*p) >= 0 )
3548
+ } else
3523
3549
  goto st0;
3524
3550
  goto st121;
3525
3551
  }
@@ -3651,7 +3677,7 @@ case 121:
3651
3677
  _out: {}
3652
3678
  }
3653
3679
 
3654
- #line 468 "pitchfork_http.rl"
3680
+ #line 494 "pitchfork_http.rl"
3655
3681
  post_exec: /* "_out:" also goes here */
3656
3682
  if (hp->cs != http_parser_error)
3657
3683
  hp->cs = cs;
@@ -4083,7 +4109,8 @@ static VALUE HttpParser_filter_body(VALUE self, VALUE dst, VALUE src)
4083
4109
  if (HP_FL_TEST(hp, CHUNKED)) {
4084
4110
  if (!chunked_eof(hp)) {
4085
4111
  rb_str_modify(dst);
4086
- rb_str_resize(dst, srclen); /* we can never copy more than srclen bytes */
4112
+ rb_str_set_len(dst, 0);
4113
+ rb_str_modify_expand(dst, srclen); /* we can never copy more than srclen bytes */
4087
4114
 
4088
4115
  hp->s.dest_offset = 0;
4089
4116
  RB_OBJ_WRITE(self, &hp->cont, dst);
@@ -4094,8 +4121,12 @@ static VALUE HttpParser_filter_body(VALUE self, VALUE dst, VALUE src)
4094
4121
 
4095
4122
  assert(hp->s.dest_offset <= hp->offset &&
4096
4123
  "destination buffer overflow");
4097
- advance_str(src, hp->offset);
4124
+ /*
4125
+ * set the decoded length before advance_str can allocate: GC
4126
+ * compaction may re-embed dst and only copies its logical length
4127
+ */
4098
4128
  rb_str_set_len(dst, hp->s.dest_offset);
4129
+ advance_str(src, hp->offset);
4099
4130
 
4100
4131
  if (RSTRING_LEN(dst) == 0 && chunked_eof(hp)) {
4101
4132
  assert(hp->len.chunk == 0 && "chunk at EOF but more to parse");