pitchfork 0.18.1 → 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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/actions.lock +40 -0
  3. data/.github/workflows/ci.yml +30 -11
  4. data/.github/workflows/release.yml +29 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +16 -2
  7. data/Gemfile +1 -0
  8. data/Rakefile +15 -0
  9. data/benchmark/request_benchmark.rb +86 -0
  10. data/docs/CONFIGURATION.md +51 -14
  11. data/docs/MIGRATING_FROM_UNICORN.md +6 -0
  12. data/docs/SIGNALS.md +6 -0
  13. data/examples/pitchfork.conf.reload.rb +41 -0
  14. data/exe/pitchfork +3 -2
  15. data/ext/pitchfork_http/c_util.h +3 -8
  16. data/ext/pitchfork_http/child_subreaper.h +7 -1
  17. data/ext/pitchfork_http/epollexclusive.h +6 -3
  18. data/ext/pitchfork_http/extconf.rb +1 -0
  19. data/ext/pitchfork_http/global_variables.h +2 -0
  20. data/ext/pitchfork_http/memory_page.c +188 -25
  21. data/ext/pitchfork_http/pitchfork_http.c +578 -471
  22. data/ext/pitchfork_http/pitchfork_http.rl +63 -33
  23. data/ext/pitchfork_http/pitchfork_http_common.rl +1 -1
  24. data/lib/pitchfork/children.rb +74 -20
  25. data/lib/pitchfork/chunked.rb +9 -0
  26. data/lib/pitchfork/configurator.rb +25 -6
  27. data/lib/pitchfork/http_parser.rb +4 -0
  28. data/lib/pitchfork/http_response.rb +35 -12
  29. data/lib/pitchfork/http_server.rb +391 -193
  30. data/lib/pitchfork/info.rb +8 -0
  31. data/lib/pitchfork/listeners.rb +52 -0
  32. data/lib/pitchfork/message.rb +58 -8
  33. data/lib/pitchfork/shared_memory.rb +64 -13
  34. data/lib/pitchfork/socket_helper.rb +6 -2
  35. data/lib/pitchfork/stream_input.rb +12 -9
  36. data/lib/pitchfork/version.rb +1 -1
  37. data/lib/pitchfork/worker.rb +124 -64
  38. data/lib/pitchfork.rb +15 -7
  39. metadata +7 -6
@@ -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 426 "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 430 "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 442 "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,113 +496,125 @@ 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
  {
515
+ VALUE str;
516
+
490
517
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
491
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
518
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
519
+
520
+ if (STR_CSTR_EQ(str, "*")) {
521
+ rb_hash_aset(hp->env, g_path_info, str);
522
+ }
492
523
  }
493
524
  goto st5;
494
- tr42:
495
- #line 328 "pitchfork_http.rl"
525
+ tr41:
526
+ #line 353 "pitchfork_http.rl"
496
527
  {MARK(mark, p); }
497
- #line 346 "pitchfork_http.rl"
528
+ #line 377 "pitchfork_http.rl"
498
529
  {
499
530
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
500
- VALUE str = rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
501
- if (STR_CSTR_EQ(str, "*")) {
502
- VALUE str = rb_str_new("*", 1);
503
- rb_hash_aset(hp->env, g_path_info, str);
504
- rb_hash_aset(hp->env, g_request_path, str);
505
- }
531
+ rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
506
532
  }
507
533
  goto st5;
508
- tr45:
509
- #line 346 "pitchfork_http.rl"
534
+ tr44:
535
+ #line 377 "pitchfork_http.rl"
510
536
  {
511
537
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
512
- VALUE str = rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
513
- if (STR_CSTR_EQ(str, "*")) {
514
- VALUE str = rb_str_new("*", 1);
515
- rb_hash_aset(hp->env, g_path_info, str);
516
- rb_hash_aset(hp->env, g_request_path, str);
517
- }
538
+ rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
518
539
  }
519
540
  goto st5;
520
- tr49:
521
- #line 361 "pitchfork_http.rl"
541
+ tr48:
542
+ #line 387 "pitchfork_http.rl"
522
543
  {
523
544
  VALUE val;
524
545
 
525
546
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_PATH);
526
547
  val = rb_hash_aset(hp->env, g_request_path, STR_NEW(mark, p));
527
548
 
528
- /* rack says PATH_INFO must start with "/" or be empty */
529
- if (!STR_CSTR_EQ(val, "*"))
530
- rb_hash_aset(hp->env, g_path_info, val);
549
+ rb_hash_aset(hp->env, g_path_info, val);
531
550
  }
532
- #line 342 "pitchfork_http.rl"
551
+ #line 367 "pitchfork_http.rl"
533
552
  {
553
+ VALUE str;
554
+
534
555
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
535
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
556
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
557
+
558
+ if (STR_CSTR_EQ(str, "*")) {
559
+ rb_hash_aset(hp->env, g_path_info, str);
560
+ }
536
561
  }
537
562
  goto st5;
538
- tr55:
539
- #line 355 "pitchfork_http.rl"
563
+ tr54:
564
+ #line 381 "pitchfork_http.rl"
540
565
  {MARK(start.query, p); }
541
- #line 356 "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
  {
573
+ VALUE str;
574
+
548
575
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
549
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
576
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
577
+
578
+ if (STR_CSTR_EQ(str, "*")) {
579
+ rb_hash_aset(hp->env, g_path_info, str);
580
+ }
550
581
  }
551
582
  goto st5;
552
- tr59:
553
- #line 356 "pitchfork_http.rl"
583
+ tr58:
584
+ #line 382 "pitchfork_http.rl"
554
585
  {
555
586
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
556
587
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
557
588
  }
558
- #line 342 "pitchfork_http.rl"
589
+ #line 367 "pitchfork_http.rl"
559
590
  {
591
+ VALUE str;
592
+
560
593
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
561
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
594
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
595
+
596
+ if (STR_CSTR_EQ(str, "*")) {
597
+ rb_hash_aset(hp->env, g_path_info, str);
598
+ }
562
599
  }
563
600
  goto st5;
564
601
  st5:
565
602
  if ( ++p == pe )
566
603
  goto _test_eof5;
567
604
  case 5:
568
- #line 569 "pitchfork_http.c"
605
+ #line 606 "pitchfork_http.c"
569
606
  if ( (*p) == 72 )
570
607
  goto tr10;
571
608
  goto st0;
572
609
  tr10:
573
- #line 328 "pitchfork_http.rl"
610
+ #line 353 "pitchfork_http.rl"
574
611
  {MARK(mark, p); }
575
612
  goto st6;
576
613
  st6:
577
614
  if ( ++p == pe )
578
615
  goto _test_eof6;
579
616
  case 6:
580
- #line 581 "pitchfork_http.c"
617
+ #line 618 "pitchfork_http.c"
581
618
  if ( (*p) == 84 )
582
619
  goto st7;
583
620
  goto st0;
@@ -637,34 +674,34 @@ case 13:
637
674
  goto st13;
638
675
  goto st0;
639
676
  tr18:
640
- #line 360 "pitchfork_http.rl"
677
+ #line 386 "pitchfork_http.rl"
641
678
  { http_version(hp, PTR_TO(mark), LEN(mark, p)); }
642
679
  goto st14;
643
- tr26:
644
- #line 334 "pitchfork_http.rl"
680
+ tr25:
681
+ #line 359 "pitchfork_http.rl"
645
682
  { MARK(mark, p); }
646
- #line 336 "pitchfork_http.rl"
683
+ #line 361 "pitchfork_http.rl"
647
684
  { write_cont_value(hp, buffer, p); }
648
685
  goto st14;
649
- tr29:
650
- #line 336 "pitchfork_http.rl"
686
+ tr30:
687
+ #line 361 "pitchfork_http.rl"
651
688
  { write_cont_value(hp, buffer, p); }
652
689
  goto st14;
653
- tr36:
654
- #line 334 "pitchfork_http.rl"
690
+ tr35:
691
+ #line 359 "pitchfork_http.rl"
655
692
  { MARK(mark, p); }
656
- #line 335 "pitchfork_http.rl"
693
+ #line 360 "pitchfork_http.rl"
657
694
  { write_value(self, hp, buffer, p); }
658
695
  goto st14;
659
696
  tr39:
660
- #line 335 "pitchfork_http.rl"
697
+ #line 360 "pitchfork_http.rl"
661
698
  { write_value(self, hp, buffer, p); }
662
699
  goto st14;
663
700
  st14:
664
701
  if ( ++p == pe )
665
702
  goto _test_eof14;
666
703
  case 14:
667
- #line 668 "pitchfork_http.c"
704
+ #line 705 "pitchfork_http.c"
668
705
  switch( (*p) ) {
669
706
  case 9: goto st15;
670
707
  case 10: goto tr21;
@@ -692,79 +729,79 @@ case 14:
692
729
  } else
693
730
  goto tr23;
694
731
  goto st0;
695
- tr25:
696
- #line 334 "pitchfork_http.rl"
732
+ tr24:
733
+ #line 359 "pitchfork_http.rl"
697
734
  { MARK(mark, p); }
698
735
  goto st15;
699
736
  st15:
700
737
  if ( ++p == pe )
701
738
  goto _test_eof15;
702
739
  case 15:
703
- #line 704 "pitchfork_http.c"
704
- switch( (*p) ) {
705
- case 9: goto tr25;
706
- case 10: goto tr26;
707
- case 13: goto tr27;
708
- case 32: goto tr25;
709
- case 127: goto st0;
710
- }
711
- if ( 0 <= (*p) && (*p) <= 31 )
712
- goto st0;
713
- goto tr24;
714
- tr24:
715
- #line 334 "pitchfork_http.rl"
716
- { MARK(mark, p); }
717
- goto st16;
718
- st16:
719
- if ( ++p == pe )
720
- goto _test_eof16;
721
- case 16:
722
- #line 723 "pitchfork_http.c"
740
+ #line 741 "pitchfork_http.c"
723
741
  switch( (*p) ) {
724
- case 10: goto tr29;
725
- case 13: goto tr30;
742
+ case 9: goto tr24;
743
+ case 10: goto tr25;
744
+ case 13: goto tr26;
745
+ case 32: goto tr24;
726
746
  case 127: goto st0;
727
747
  }
728
- if ( (*p) > 8 ) {
729
- if ( 11 <= (*p) && (*p) <= 31 )
730
- goto st0;
731
- } else if ( (*p) >= 0 )
748
+ if ( (*p) <= 31 )
732
749
  goto st0;
733
- goto st16;
750
+ goto tr27;
734
751
  tr19:
735
- #line 360 "pitchfork_http.rl"
752
+ #line 386 "pitchfork_http.rl"
736
753
  { http_version(hp, PTR_TO(mark), LEN(mark, p)); }
737
- goto st17;
738
- tr27:
739
- #line 334 "pitchfork_http.rl"
754
+ goto st16;
755
+ tr26:
756
+ #line 359 "pitchfork_http.rl"
740
757
  { MARK(mark, p); }
741
- #line 336 "pitchfork_http.rl"
758
+ #line 361 "pitchfork_http.rl"
742
759
  { write_cont_value(hp, buffer, p); }
743
- goto st17;
744
- tr30:
745
- #line 336 "pitchfork_http.rl"
760
+ goto st16;
761
+ tr31:
762
+ #line 361 "pitchfork_http.rl"
746
763
  { write_cont_value(hp, buffer, p); }
747
- goto st17;
748
- tr37:
749
- #line 334 "pitchfork_http.rl"
764
+ goto st16;
765
+ tr36:
766
+ #line 359 "pitchfork_http.rl"
750
767
  { MARK(mark, p); }
751
- #line 335 "pitchfork_http.rl"
768
+ #line 360 "pitchfork_http.rl"
752
769
  { write_value(self, hp, buffer, p); }
753
- goto st17;
770
+ goto st16;
754
771
  tr40:
755
- #line 335 "pitchfork_http.rl"
772
+ #line 360 "pitchfork_http.rl"
756
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); }
757
786
  goto st17;
758
787
  st17:
759
788
  if ( ++p == pe )
760
789
  goto _test_eof17;
761
790
  case 17:
762
- #line 763 "pitchfork_http.c"
763
- if ( (*p) == 10 )
764
- goto st14;
765
- 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;
766
803
  tr21:
767
- #line 376 "pitchfork_http.rl"
804
+ #line 400 "pitchfork_http.rl"
768
805
  {
769
806
  finalize_header(hp);
770
807
 
@@ -785,12 +822,18 @@ tr21:
785
822
  }
786
823
  goto st122;
787
824
  tr104:
788
- #line 342 "pitchfork_http.rl"
825
+ #line 367 "pitchfork_http.rl"
789
826
  {
827
+ VALUE str;
828
+
790
829
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
791
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
830
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
831
+
832
+ if (STR_CSTR_EQ(str, "*")) {
833
+ rb_hash_aset(hp->env, g_path_info, str);
834
+ }
792
835
  }
793
- #line 376 "pitchfork_http.rl"
836
+ #line 400 "pitchfork_http.rl"
794
837
  {
795
838
  finalize_header(hp);
796
839
 
@@ -810,20 +853,15 @@ tr104:
810
853
  goto post_exec;
811
854
  }
812
855
  goto st122;
813
- tr108:
814
- #line 328 "pitchfork_http.rl"
856
+ tr107:
857
+ #line 353 "pitchfork_http.rl"
815
858
  {MARK(mark, p); }
816
- #line 346 "pitchfork_http.rl"
859
+ #line 377 "pitchfork_http.rl"
817
860
  {
818
861
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
819
- VALUE str = rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
820
- if (STR_CSTR_EQ(str, "*")) {
821
- VALUE str = rb_str_new("*", 1);
822
- rb_hash_aset(hp->env, g_path_info, str);
823
- rb_hash_aset(hp->env, g_request_path, str);
824
- }
862
+ rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
825
863
  }
826
- #line 376 "pitchfork_http.rl"
864
+ #line 400 "pitchfork_http.rl"
827
865
  {
828
866
  finalize_header(hp);
829
867
 
@@ -843,18 +881,13 @@ tr108:
843
881
  goto post_exec;
844
882
  }
845
883
  goto st122;
846
- tr112:
847
- #line 346 "pitchfork_http.rl"
884
+ tr111:
885
+ #line 377 "pitchfork_http.rl"
848
886
  {
849
887
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
850
- VALUE str = rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
851
- if (STR_CSTR_EQ(str, "*")) {
852
- VALUE str = rb_str_new("*", 1);
853
- rb_hash_aset(hp->env, g_path_info, str);
854
- rb_hash_aset(hp->env, g_request_path, str);
855
- }
888
+ rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
856
889
  }
857
- #line 376 "pitchfork_http.rl"
890
+ #line 400 "pitchfork_http.rl"
858
891
  {
859
892
  finalize_header(hp);
860
893
 
@@ -874,24 +907,28 @@ tr112:
874
907
  goto post_exec;
875
908
  }
876
909
  goto st122;
877
- tr117:
878
- #line 361 "pitchfork_http.rl"
910
+ tr116:
911
+ #line 387 "pitchfork_http.rl"
879
912
  {
880
913
  VALUE val;
881
914
 
882
915
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_PATH);
883
916
  val = rb_hash_aset(hp->env, g_request_path, STR_NEW(mark, p));
884
917
 
885
- /* rack says PATH_INFO must start with "/" or be empty */
886
- if (!STR_CSTR_EQ(val, "*"))
887
- rb_hash_aset(hp->env, g_path_info, val);
918
+ rb_hash_aset(hp->env, g_path_info, val);
888
919
  }
889
- #line 342 "pitchfork_http.rl"
920
+ #line 367 "pitchfork_http.rl"
890
921
  {
922
+ VALUE str;
923
+
891
924
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
892
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
925
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
926
+
927
+ if (STR_CSTR_EQ(str, "*")) {
928
+ rb_hash_aset(hp->env, g_path_info, str);
929
+ }
893
930
  }
894
- #line 376 "pitchfork_http.rl"
931
+ #line 400 "pitchfork_http.rl"
895
932
  {
896
933
  finalize_header(hp);
897
934
 
@@ -911,20 +948,26 @@ tr117:
911
948
  goto post_exec;
912
949
  }
913
950
  goto st122;
914
- tr124:
915
- #line 355 "pitchfork_http.rl"
951
+ tr123:
952
+ #line 381 "pitchfork_http.rl"
916
953
  {MARK(start.query, p); }
917
- #line 356 "pitchfork_http.rl"
954
+ #line 382 "pitchfork_http.rl"
918
955
  {
919
956
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
920
957
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
921
958
  }
922
- #line 342 "pitchfork_http.rl"
959
+ #line 367 "pitchfork_http.rl"
923
960
  {
961
+ VALUE str;
962
+
924
963
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
925
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
964
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
965
+
966
+ if (STR_CSTR_EQ(str, "*")) {
967
+ rb_hash_aset(hp->env, g_path_info, str);
968
+ }
926
969
  }
927
- #line 376 "pitchfork_http.rl"
970
+ #line 400 "pitchfork_http.rl"
928
971
  {
929
972
  finalize_header(hp);
930
973
 
@@ -944,18 +987,24 @@ tr124:
944
987
  goto post_exec;
945
988
  }
946
989
  goto st122;
947
- tr129:
948
- #line 356 "pitchfork_http.rl"
990
+ tr128:
991
+ #line 382 "pitchfork_http.rl"
949
992
  {
950
993
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
951
994
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
952
995
  }
953
- #line 342 "pitchfork_http.rl"
996
+ #line 367 "pitchfork_http.rl"
954
997
  {
998
+ VALUE str;
999
+
955
1000
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
956
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1001
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1002
+
1003
+ if (STR_CSTR_EQ(str, "*")) {
1004
+ rb_hash_aset(hp->env, g_path_info, str);
1005
+ }
957
1006
  }
958
- #line 376 "pitchfork_http.rl"
1007
+ #line 400 "pitchfork_http.rl"
959
1008
  {
960
1009
  finalize_header(hp);
961
1010
 
@@ -979,108 +1028,120 @@ st122:
979
1028
  if ( ++p == pe )
980
1029
  goto _test_eof122;
981
1030
  case 122:
982
- #line 983 "pitchfork_http.c"
1031
+ #line 1032 "pitchfork_http.c"
983
1032
  goto st0;
984
1033
  tr105:
985
- #line 342 "pitchfork_http.rl"
1034
+ #line 367 "pitchfork_http.rl"
986
1035
  {
1036
+ VALUE str;
1037
+
987
1038
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
988
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1039
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1040
+
1041
+ if (STR_CSTR_EQ(str, "*")) {
1042
+ rb_hash_aset(hp->env, g_path_info, str);
1043
+ }
989
1044
  }
990
1045
  goto st18;
991
- tr109:
992
- #line 328 "pitchfork_http.rl"
1046
+ tr108:
1047
+ #line 353 "pitchfork_http.rl"
993
1048
  {MARK(mark, p); }
994
- #line 346 "pitchfork_http.rl"
1049
+ #line 377 "pitchfork_http.rl"
995
1050
  {
996
1051
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
997
- VALUE str = rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
998
- if (STR_CSTR_EQ(str, "*")) {
999
- VALUE str = rb_str_new("*", 1);
1000
- rb_hash_aset(hp->env, g_path_info, str);
1001
- rb_hash_aset(hp->env, g_request_path, str);
1002
- }
1052
+ rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
1003
1053
  }
1004
1054
  goto st18;
1005
- tr113:
1006
- #line 346 "pitchfork_http.rl"
1055
+ tr112:
1056
+ #line 377 "pitchfork_http.rl"
1007
1057
  {
1008
1058
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), FRAGMENT);
1009
- VALUE str = rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
1010
- if (STR_CSTR_EQ(str, "*")) {
1011
- VALUE str = rb_str_new("*", 1);
1012
- rb_hash_aset(hp->env, g_path_info, str);
1013
- rb_hash_aset(hp->env, g_request_path, str);
1014
- }
1059
+ rb_hash_aset(hp->env, g_fragment, STR_NEW(mark, p));
1015
1060
  }
1016
1061
  goto st18;
1017
- tr118:
1018
- #line 361 "pitchfork_http.rl"
1062
+ tr117:
1063
+ #line 387 "pitchfork_http.rl"
1019
1064
  {
1020
1065
  VALUE val;
1021
1066
 
1022
1067
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_PATH);
1023
1068
  val = rb_hash_aset(hp->env, g_request_path, STR_NEW(mark, p));
1024
1069
 
1025
- /* rack says PATH_INFO must start with "/" or be empty */
1026
- if (!STR_CSTR_EQ(val, "*"))
1027
- rb_hash_aset(hp->env, g_path_info, val);
1070
+ rb_hash_aset(hp->env, g_path_info, val);
1028
1071
  }
1029
- #line 342 "pitchfork_http.rl"
1072
+ #line 367 "pitchfork_http.rl"
1030
1073
  {
1074
+ VALUE str;
1075
+
1031
1076
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
1032
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1077
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1078
+
1079
+ if (STR_CSTR_EQ(str, "*")) {
1080
+ rb_hash_aset(hp->env, g_path_info, str);
1081
+ }
1033
1082
  }
1034
1083
  goto st18;
1035
- tr125:
1036
- #line 355 "pitchfork_http.rl"
1084
+ tr124:
1085
+ #line 381 "pitchfork_http.rl"
1037
1086
  {MARK(start.query, p); }
1038
- #line 356 "pitchfork_http.rl"
1087
+ #line 382 "pitchfork_http.rl"
1039
1088
  {
1040
1089
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1041
1090
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1042
1091
  }
1043
- #line 342 "pitchfork_http.rl"
1092
+ #line 367 "pitchfork_http.rl"
1044
1093
  {
1094
+ VALUE str;
1095
+
1045
1096
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
1046
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1097
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1098
+
1099
+ if (STR_CSTR_EQ(str, "*")) {
1100
+ rb_hash_aset(hp->env, g_path_info, str);
1101
+ }
1047
1102
  }
1048
1103
  goto st18;
1049
- tr130:
1050
- #line 356 "pitchfork_http.rl"
1104
+ tr129:
1105
+ #line 382 "pitchfork_http.rl"
1051
1106
  {
1052
1107
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1053
1108
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1054
1109
  }
1055
- #line 342 "pitchfork_http.rl"
1110
+ #line 367 "pitchfork_http.rl"
1056
1111
  {
1112
+ VALUE str;
1113
+
1057
1114
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
1058
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1115
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1116
+
1117
+ if (STR_CSTR_EQ(str, "*")) {
1118
+ rb_hash_aset(hp->env, g_path_info, str);
1119
+ }
1059
1120
  }
1060
1121
  goto st18;
1061
1122
  st18:
1062
1123
  if ( ++p == pe )
1063
1124
  goto _test_eof18;
1064
1125
  case 18:
1065
- #line 1066 "pitchfork_http.c"
1126
+ #line 1127 "pitchfork_http.c"
1066
1127
  if ( (*p) == 10 )
1067
1128
  goto tr21;
1068
1129
  goto st0;
1069
1130
  tr23:
1070
- #line 330 "pitchfork_http.rl"
1131
+ #line 355 "pitchfork_http.rl"
1071
1132
  { MARK(start.field, p); }
1072
- #line 331 "pitchfork_http.rl"
1073
- { snake_upcase_char(deconst(p)); }
1133
+ #line 356 "pitchfork_http.rl"
1134
+ { upcase_char(deconst(p)); }
1074
1135
  goto st19;
1075
1136
  tr32:
1076
- #line 331 "pitchfork_http.rl"
1077
- { snake_upcase_char(deconst(p)); }
1137
+ #line 356 "pitchfork_http.rl"
1138
+ { upcase_char(deconst(p)); }
1078
1139
  goto st19;
1079
1140
  st19:
1080
1141
  if ( ++p == pe )
1081
1142
  goto _test_eof19;
1082
1143
  case 19:
1083
- #line 1084 "pitchfork_http.c"
1144
+ #line 1145 "pitchfork_http.c"
1084
1145
  switch( (*p) ) {
1085
1146
  case 33: goto tr32;
1086
1147
  case 58: goto tr33;
@@ -1105,38 +1166,38 @@ case 19:
1105
1166
  } else
1106
1167
  goto tr32;
1107
1168
  goto st0;
1108
- tr35:
1109
- #line 334 "pitchfork_http.rl"
1169
+ tr34:
1170
+ #line 359 "pitchfork_http.rl"
1110
1171
  { MARK(mark, p); }
1111
1172
  goto st20;
1112
1173
  tr33:
1113
- #line 333 "pitchfork_http.rl"
1174
+ #line 358 "pitchfork_http.rl"
1114
1175
  { hp->s.field_len = LEN(start.field, p); }
1115
1176
  goto st20;
1116
1177
  st20:
1117
1178
  if ( ++p == pe )
1118
1179
  goto _test_eof20;
1119
1180
  case 20:
1120
- #line 1121 "pitchfork_http.c"
1181
+ #line 1182 "pitchfork_http.c"
1121
1182
  switch( (*p) ) {
1122
- case 9: goto tr35;
1123
- case 10: goto tr36;
1124
- case 13: goto tr37;
1125
- case 32: goto tr35;
1183
+ case 9: goto tr34;
1184
+ case 10: goto tr35;
1185
+ case 13: goto tr36;
1186
+ case 32: goto tr34;
1126
1187
  case 127: goto st0;
1127
1188
  }
1128
- if ( 0 <= (*p) && (*p) <= 31 )
1189
+ if ( (*p) <= 31 )
1129
1190
  goto st0;
1130
- goto tr34;
1131
- tr34:
1132
- #line 334 "pitchfork_http.rl"
1191
+ goto tr37;
1192
+ tr37:
1193
+ #line 359 "pitchfork_http.rl"
1133
1194
  { MARK(mark, p); }
1134
1195
  goto st21;
1135
1196
  st21:
1136
1197
  if ( ++p == pe )
1137
1198
  goto _test_eof21;
1138
1199
  case 21:
1139
- #line 1140 "pitchfork_http.c"
1200
+ #line 1201 "pitchfork_http.c"
1140
1201
  switch( (*p) ) {
1141
1202
  case 10: goto tr39;
1142
1203
  case 13: goto tr40;
@@ -1145,101 +1206,123 @@ case 21:
1145
1206
  if ( (*p) > 8 ) {
1146
1207
  if ( 11 <= (*p) && (*p) <= 31 )
1147
1208
  goto st0;
1148
- } else if ( (*p) >= 0 )
1209
+ } else
1149
1210
  goto st0;
1150
1211
  goto st21;
1151
1212
  tr9:
1152
- #line 342 "pitchfork_http.rl"
1213
+ #line 367 "pitchfork_http.rl"
1153
1214
  {
1215
+ VALUE str;
1216
+
1154
1217
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
1155
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1218
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1219
+
1220
+ if (STR_CSTR_EQ(str, "*")) {
1221
+ rb_hash_aset(hp->env, g_path_info, str);
1222
+ }
1156
1223
  }
1157
1224
  goto st22;
1158
1225
  tr50:
1159
- #line 361 "pitchfork_http.rl"
1226
+ #line 387 "pitchfork_http.rl"
1160
1227
  {
1161
1228
  VALUE val;
1162
1229
 
1163
1230
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_PATH);
1164
1231
  val = rb_hash_aset(hp->env, g_request_path, STR_NEW(mark, p));
1165
1232
 
1166
- /* rack says PATH_INFO must start with "/" or be empty */
1167
- if (!STR_CSTR_EQ(val, "*"))
1168
- rb_hash_aset(hp->env, g_path_info, val);
1233
+ rb_hash_aset(hp->env, g_path_info, val);
1169
1234
  }
1170
- #line 342 "pitchfork_http.rl"
1235
+ #line 367 "pitchfork_http.rl"
1171
1236
  {
1237
+ VALUE str;
1238
+
1172
1239
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
1173
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1240
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1241
+
1242
+ if (STR_CSTR_EQ(str, "*")) {
1243
+ rb_hash_aset(hp->env, g_path_info, str);
1244
+ }
1174
1245
  }
1175
1246
  goto st22;
1176
1247
  tr56:
1177
- #line 355 "pitchfork_http.rl"
1248
+ #line 381 "pitchfork_http.rl"
1178
1249
  {MARK(start.query, p); }
1179
- #line 356 "pitchfork_http.rl"
1250
+ #line 382 "pitchfork_http.rl"
1180
1251
  {
1181
1252
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1182
1253
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1183
1254
  }
1184
- #line 342 "pitchfork_http.rl"
1255
+ #line 367 "pitchfork_http.rl"
1185
1256
  {
1257
+ VALUE str;
1258
+
1186
1259
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
1187
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1260
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1261
+
1262
+ if (STR_CSTR_EQ(str, "*")) {
1263
+ rb_hash_aset(hp->env, g_path_info, str);
1264
+ }
1188
1265
  }
1189
1266
  goto st22;
1190
1267
  tr60:
1191
- #line 356 "pitchfork_http.rl"
1268
+ #line 382 "pitchfork_http.rl"
1192
1269
  {
1193
1270
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
1194
1271
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
1195
1272
  }
1196
- #line 342 "pitchfork_http.rl"
1273
+ #line 367 "pitchfork_http.rl"
1197
1274
  {
1275
+ VALUE str;
1276
+
1198
1277
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
1199
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1278
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
1279
+
1280
+ if (STR_CSTR_EQ(str, "*")) {
1281
+ rb_hash_aset(hp->env, g_path_info, str);
1282
+ }
1200
1283
  }
1201
1284
  goto st22;
1202
1285
  st22:
1203
1286
  if ( ++p == pe )
1204
1287
  goto _test_eof22;
1205
1288
  case 22:
1206
- #line 1207 "pitchfork_http.c"
1289
+ #line 1290 "pitchfork_http.c"
1207
1290
  switch( (*p) ) {
1208
- case 32: goto tr42;
1291
+ case 32: goto tr41;
1209
1292
  case 35: goto st0;
1210
1293
  case 37: goto tr43;
1211
1294
  case 127: goto st0;
1212
1295
  }
1213
- if ( 0 <= (*p) && (*p) <= 31 )
1296
+ if ( (*p) <= 31 )
1214
1297
  goto st0;
1215
- goto tr41;
1216
- tr41:
1217
- #line 328 "pitchfork_http.rl"
1298
+ goto tr42;
1299
+ tr42:
1300
+ #line 353 "pitchfork_http.rl"
1218
1301
  {MARK(mark, p); }
1219
1302
  goto st23;
1220
1303
  st23:
1221
1304
  if ( ++p == pe )
1222
1305
  goto _test_eof23;
1223
1306
  case 23:
1224
- #line 1225 "pitchfork_http.c"
1307
+ #line 1308 "pitchfork_http.c"
1225
1308
  switch( (*p) ) {
1226
- case 32: goto tr45;
1309
+ case 32: goto tr44;
1227
1310
  case 35: goto st0;
1228
1311
  case 37: goto st24;
1229
1312
  case 127: goto st0;
1230
1313
  }
1231
- if ( 0 <= (*p) && (*p) <= 31 )
1314
+ if ( (*p) <= 31 )
1232
1315
  goto st0;
1233
1316
  goto st23;
1234
1317
  tr43:
1235
- #line 328 "pitchfork_http.rl"
1318
+ #line 353 "pitchfork_http.rl"
1236
1319
  {MARK(mark, p); }
1237
1320
  goto st24;
1238
1321
  st24:
1239
1322
  if ( ++p == pe )
1240
1323
  goto _test_eof24;
1241
1324
  case 24:
1242
- #line 1243 "pitchfork_http.c"
1325
+ #line 1326 "pitchfork_http.c"
1243
1326
  if ( (*p) < 65 ) {
1244
1327
  if ( 48 <= (*p) && (*p) <= 57 )
1245
1328
  goto st25;
@@ -1263,28 +1346,28 @@ case 25:
1263
1346
  goto st23;
1264
1347
  goto st0;
1265
1348
  tr6:
1266
- #line 328 "pitchfork_http.rl"
1349
+ #line 353 "pitchfork_http.rl"
1267
1350
  {MARK(mark, p); }
1268
1351
  goto st26;
1269
1352
  tr76:
1270
- #line 341 "pitchfork_http.rl"
1353
+ #line 366 "pitchfork_http.rl"
1271
1354
  { rb_hash_aset(hp->env, g_http_host, STR_NEW(mark, p)); }
1272
- #line 328 "pitchfork_http.rl"
1355
+ #line 353 "pitchfork_http.rl"
1273
1356
  {MARK(mark, p); }
1274
1357
  goto st26;
1275
1358
  st26:
1276
1359
  if ( ++p == pe )
1277
1360
  goto _test_eof26;
1278
1361
  case 26:
1279
- #line 1280 "pitchfork_http.c"
1362
+ #line 1363 "pitchfork_http.c"
1280
1363
  switch( (*p) ) {
1281
- case 32: goto tr49;
1364
+ case 32: goto tr48;
1282
1365
  case 35: goto tr50;
1283
1366
  case 37: goto st27;
1284
1367
  case 63: goto tr52;
1285
1368
  case 127: goto st0;
1286
1369
  }
1287
- if ( 0 <= (*p) && (*p) <= 31 )
1370
+ if ( (*p) <= 31 )
1288
1371
  goto st0;
1289
1372
  goto st26;
1290
1373
  st27:
@@ -1314,59 +1397,57 @@ case 28:
1314
1397
  goto st26;
1315
1398
  goto st0;
1316
1399
  tr52:
1317
- #line 361 "pitchfork_http.rl"
1400
+ #line 387 "pitchfork_http.rl"
1318
1401
  {
1319
1402
  VALUE val;
1320
1403
 
1321
1404
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_PATH);
1322
1405
  val = rb_hash_aset(hp->env, g_request_path, STR_NEW(mark, p));
1323
1406
 
1324
- /* rack says PATH_INFO must start with "/" or be empty */
1325
- if (!STR_CSTR_EQ(val, "*"))
1326
- rb_hash_aset(hp->env, g_path_info, val);
1407
+ rb_hash_aset(hp->env, g_path_info, val);
1327
1408
  }
1328
1409
  goto st29;
1329
1410
  st29:
1330
1411
  if ( ++p == pe )
1331
1412
  goto _test_eof29;
1332
1413
  case 29:
1333
- #line 1334 "pitchfork_http.c"
1414
+ #line 1415 "pitchfork_http.c"
1334
1415
  switch( (*p) ) {
1335
- case 32: goto tr55;
1416
+ case 32: goto tr54;
1336
1417
  case 35: goto tr56;
1337
1418
  case 37: goto tr57;
1338
1419
  case 127: goto st0;
1339
1420
  }
1340
- if ( 0 <= (*p) && (*p) <= 31 )
1421
+ if ( (*p) <= 31 )
1341
1422
  goto st0;
1342
- goto tr54;
1343
- tr54:
1344
- #line 355 "pitchfork_http.rl"
1423
+ goto tr55;
1424
+ tr55:
1425
+ #line 381 "pitchfork_http.rl"
1345
1426
  {MARK(start.query, p); }
1346
1427
  goto st30;
1347
1428
  st30:
1348
1429
  if ( ++p == pe )
1349
1430
  goto _test_eof30;
1350
1431
  case 30:
1351
- #line 1352 "pitchfork_http.c"
1432
+ #line 1433 "pitchfork_http.c"
1352
1433
  switch( (*p) ) {
1353
- case 32: goto tr59;
1434
+ case 32: goto tr58;
1354
1435
  case 35: goto tr60;
1355
1436
  case 37: goto st31;
1356
1437
  case 127: goto st0;
1357
1438
  }
1358
- if ( 0 <= (*p) && (*p) <= 31 )
1439
+ if ( (*p) <= 31 )
1359
1440
  goto st0;
1360
1441
  goto st30;
1361
1442
  tr57:
1362
- #line 355 "pitchfork_http.rl"
1443
+ #line 381 "pitchfork_http.rl"
1363
1444
  {MARK(start.query, p); }
1364
1445
  goto st31;
1365
1446
  st31:
1366
1447
  if ( ++p == pe )
1367
1448
  goto _test_eof31;
1368
1449
  case 31:
1369
- #line 1370 "pitchfork_http.c"
1450
+ #line 1451 "pitchfork_http.c"
1370
1451
  if ( (*p) < 65 ) {
1371
1452
  if ( 48 <= (*p) && (*p) <= 57 )
1372
1453
  goto st32;
@@ -1390,58 +1471,58 @@ case 32:
1390
1471
  goto st30;
1391
1472
  goto st0;
1392
1473
  tr7:
1393
- #line 328 "pitchfork_http.rl"
1474
+ #line 353 "pitchfork_http.rl"
1394
1475
  {MARK(mark, p); }
1395
- #line 332 "pitchfork_http.rl"
1476
+ #line 357 "pitchfork_http.rl"
1396
1477
  { downcase_char(deconst(p)); }
1397
1478
  goto st33;
1398
1479
  st33:
1399
1480
  if ( ++p == pe )
1400
1481
  goto _test_eof33;
1401
1482
  case 33:
1402
- #line 1403 "pitchfork_http.c"
1483
+ #line 1484 "pitchfork_http.c"
1403
1484
  switch( (*p) ) {
1404
1485
  case 84: goto tr63;
1405
1486
  case 116: goto tr63;
1406
1487
  }
1407
1488
  goto st0;
1408
1489
  tr63:
1409
- #line 332 "pitchfork_http.rl"
1490
+ #line 357 "pitchfork_http.rl"
1410
1491
  { downcase_char(deconst(p)); }
1411
1492
  goto st34;
1412
1493
  st34:
1413
1494
  if ( ++p == pe )
1414
1495
  goto _test_eof34;
1415
1496
  case 34:
1416
- #line 1417 "pitchfork_http.c"
1497
+ #line 1498 "pitchfork_http.c"
1417
1498
  switch( (*p) ) {
1418
1499
  case 84: goto tr64;
1419
1500
  case 116: goto tr64;
1420
1501
  }
1421
1502
  goto st0;
1422
1503
  tr64:
1423
- #line 332 "pitchfork_http.rl"
1504
+ #line 357 "pitchfork_http.rl"
1424
1505
  { downcase_char(deconst(p)); }
1425
1506
  goto st35;
1426
1507
  st35:
1427
1508
  if ( ++p == pe )
1428
1509
  goto _test_eof35;
1429
1510
  case 35:
1430
- #line 1431 "pitchfork_http.c"
1511
+ #line 1512 "pitchfork_http.c"
1431
1512
  switch( (*p) ) {
1432
1513
  case 80: goto tr65;
1433
1514
  case 112: goto tr65;
1434
1515
  }
1435
1516
  goto st0;
1436
1517
  tr65:
1437
- #line 332 "pitchfork_http.rl"
1518
+ #line 357 "pitchfork_http.rl"
1438
1519
  { downcase_char(deconst(p)); }
1439
1520
  goto st36;
1440
1521
  st36:
1441
1522
  if ( ++p == pe )
1442
1523
  goto _test_eof36;
1443
1524
  case 36:
1444
- #line 1445 "pitchfork_http.c"
1525
+ #line 1526 "pitchfork_http.c"
1445
1526
  switch( (*p) ) {
1446
1527
  case 58: goto tr66;
1447
1528
  case 83: goto tr67;
@@ -1449,7 +1530,7 @@ case 36:
1449
1530
  }
1450
1531
  goto st0;
1451
1532
  tr66:
1452
- #line 338 "pitchfork_http.rl"
1533
+ #line 363 "pitchfork_http.rl"
1453
1534
  {
1454
1535
  rb_hash_aset(hp->env, g_rack_url_scheme, STR_NEW(mark, p));
1455
1536
  }
@@ -1458,7 +1539,7 @@ st37:
1458
1539
  if ( ++p == pe )
1459
1540
  goto _test_eof37;
1460
1541
  case 37:
1461
- #line 1462 "pitchfork_http.c"
1542
+ #line 1543 "pitchfork_http.c"
1462
1543
  if ( (*p) == 47 )
1463
1544
  goto st38;
1464
1545
  goto st0;
@@ -1485,7 +1566,7 @@ case 39:
1485
1566
  if ( (*p) > 32 ) {
1486
1567
  if ( 34 <= (*p) && (*p) <= 35 )
1487
1568
  goto st0;
1488
- } else if ( (*p) >= 0 )
1569
+ } else
1489
1570
  goto st0;
1490
1571
  } else if ( (*p) > 57 ) {
1491
1572
  if ( (*p) < 65 ) {
@@ -1511,7 +1592,7 @@ case 40:
1511
1592
  case 127: goto st0;
1512
1593
  }
1513
1594
  if ( (*p) < 34 ) {
1514
- if ( 0 <= (*p) && (*p) <= 32 )
1595
+ if ( (*p) <= 32 )
1515
1596
  goto st0;
1516
1597
  } else if ( (*p) > 35 ) {
1517
1598
  if ( 62 <= (*p) && (*p) <= 63 )
@@ -1546,14 +1627,14 @@ case 42:
1546
1627
  goto st40;
1547
1628
  goto st0;
1548
1629
  tr72:
1549
- #line 328 "pitchfork_http.rl"
1630
+ #line 353 "pitchfork_http.rl"
1550
1631
  {MARK(mark, p); }
1551
1632
  goto st43;
1552
1633
  st43:
1553
1634
  if ( ++p == pe )
1554
1635
  goto _test_eof43;
1555
1636
  case 43:
1556
- #line 1557 "pitchfork_http.c"
1637
+ #line 1638 "pitchfork_http.c"
1557
1638
  switch( (*p) ) {
1558
1639
  case 37: goto st41;
1559
1640
  case 47: goto tr76;
@@ -1567,7 +1648,7 @@ case 43:
1567
1648
  if ( (*p) > 32 ) {
1568
1649
  if ( 34 <= (*p) && (*p) <= 35 )
1569
1650
  goto st0;
1570
- } else if ( (*p) >= 0 )
1651
+ } else
1571
1652
  goto st0;
1572
1653
  } else if ( (*p) > 57 ) {
1573
1654
  if ( (*p) < 65 ) {
@@ -1593,7 +1674,7 @@ case 44:
1593
1674
  case 127: goto st0;
1594
1675
  }
1595
1676
  if ( (*p) < 34 ) {
1596
- if ( 0 <= (*p) && (*p) <= 32 )
1677
+ if ( (*p) <= 32 )
1597
1678
  goto st0;
1598
1679
  } else if ( (*p) > 35 ) {
1599
1680
  if ( (*p) > 57 ) {
@@ -1605,14 +1686,14 @@ case 44:
1605
1686
  goto st0;
1606
1687
  goto st40;
1607
1688
  tr73:
1608
- #line 328 "pitchfork_http.rl"
1689
+ #line 353 "pitchfork_http.rl"
1609
1690
  {MARK(mark, p); }
1610
1691
  goto st45;
1611
1692
  st45:
1612
1693
  if ( ++p == pe )
1613
1694
  goto _test_eof45;
1614
1695
  case 45:
1615
- #line 1616 "pitchfork_http.c"
1696
+ #line 1697 "pitchfork_http.c"
1616
1697
  switch( (*p) ) {
1617
1698
  case 37: goto st41;
1618
1699
  case 47: goto st0;
@@ -1624,7 +1705,7 @@ case 45:
1624
1705
  if ( (*p) > 32 ) {
1625
1706
  if ( 34 <= (*p) && (*p) <= 35 )
1626
1707
  goto st0;
1627
- } else if ( (*p) >= 0 )
1708
+ } else
1628
1709
  goto st0;
1629
1710
  } else if ( (*p) > 58 ) {
1630
1711
  if ( (*p) < 65 ) {
@@ -1654,7 +1735,7 @@ case 46:
1654
1735
  if ( (*p) > 32 ) {
1655
1736
  if ( 34 <= (*p) && (*p) <= 35 )
1656
1737
  goto st0;
1657
- } else if ( (*p) >= 0 )
1738
+ } else
1658
1739
  goto st0;
1659
1740
  } else if ( (*p) > 58 ) {
1660
1741
  if ( (*p) < 65 ) {
@@ -1681,7 +1762,7 @@ case 47:
1681
1762
  case 127: goto st0;
1682
1763
  }
1683
1764
  if ( (*p) < 34 ) {
1684
- if ( 0 <= (*p) && (*p) <= 32 )
1765
+ if ( (*p) <= 32 )
1685
1766
  goto st0;
1686
1767
  } else if ( (*p) > 35 ) {
1687
1768
  if ( 62 <= (*p) && (*p) <= 63 )
@@ -1690,14 +1771,14 @@ case 47:
1690
1771
  goto st0;
1691
1772
  goto st40;
1692
1773
  tr67:
1693
- #line 332 "pitchfork_http.rl"
1774
+ #line 357 "pitchfork_http.rl"
1694
1775
  { downcase_char(deconst(p)); }
1695
1776
  goto st48;
1696
1777
  st48:
1697
1778
  if ( ++p == pe )
1698
1779
  goto _test_eof48;
1699
1780
  case 48:
1700
- #line 1701 "pitchfork_http.c"
1781
+ #line 1782 "pitchfork_http.c"
1701
1782
  if ( (*p) == 58 )
1702
1783
  goto tr66;
1703
1784
  goto st0;
@@ -2213,14 +2294,14 @@ case 67:
2213
2294
  goto tr3;
2214
2295
  goto st0;
2215
2296
  tr2:
2216
- #line 328 "pitchfork_http.rl"
2297
+ #line 353 "pitchfork_http.rl"
2217
2298
  {MARK(mark, p); }
2218
2299
  goto st68;
2219
2300
  st68:
2220
2301
  if ( ++p == pe )
2221
2302
  goto _test_eof68;
2222
2303
  case 68:
2223
- #line 2224 "pitchfork_http.c"
2304
+ #line 2305 "pitchfork_http.c"
2224
2305
  switch( (*p) ) {
2225
2306
  case 32: goto tr3;
2226
2307
  case 33: goto st49;
@@ -2304,14 +2385,14 @@ case 70:
2304
2385
  goto st51;
2305
2386
  goto st0;
2306
2387
  tr100:
2307
- #line 337 "pitchfork_http.rl"
2388
+ #line 362 "pitchfork_http.rl"
2308
2389
  { request_method(hp, PTR_TO(mark), LEN(mark, p)); }
2309
2390
  goto st71;
2310
2391
  st71:
2311
2392
  if ( ++p == pe )
2312
2393
  goto _test_eof71;
2313
2394
  case 71:
2314
- #line 2315 "pitchfork_http.c"
2395
+ #line 2396 "pitchfork_http.c"
2315
2396
  switch( (*p) ) {
2316
2397
  case 42: goto tr101;
2317
2398
  case 47: goto tr102;
@@ -2320,14 +2401,14 @@ case 71:
2320
2401
  }
2321
2402
  goto st0;
2322
2403
  tr101:
2323
- #line 328 "pitchfork_http.rl"
2404
+ #line 353 "pitchfork_http.rl"
2324
2405
  {MARK(mark, p); }
2325
2406
  goto st72;
2326
2407
  st72:
2327
2408
  if ( ++p == pe )
2328
2409
  goto _test_eof72;
2329
2410
  case 72:
2330
- #line 2331 "pitchfork_http.c"
2411
+ #line 2412 "pitchfork_http.c"
2331
2412
  switch( (*p) ) {
2332
2413
  case 10: goto tr104;
2333
2414
  case 13: goto tr105;
@@ -2336,101 +2417,123 @@ case 72:
2336
2417
  }
2337
2418
  goto st0;
2338
2419
  tr106:
2339
- #line 342 "pitchfork_http.rl"
2420
+ #line 367 "pitchfork_http.rl"
2340
2421
  {
2422
+ VALUE str;
2423
+
2341
2424
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
2342
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
2425
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
2426
+
2427
+ if (STR_CSTR_EQ(str, "*")) {
2428
+ rb_hash_aset(hp->env, g_path_info, str);
2429
+ }
2343
2430
  }
2344
2431
  goto st73;
2345
2432
  tr119:
2346
- #line 361 "pitchfork_http.rl"
2433
+ #line 387 "pitchfork_http.rl"
2347
2434
  {
2348
2435
  VALUE val;
2349
2436
 
2350
2437
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_PATH);
2351
2438
  val = rb_hash_aset(hp->env, g_request_path, STR_NEW(mark, p));
2352
2439
 
2353
- /* rack says PATH_INFO must start with "/" or be empty */
2354
- if (!STR_CSTR_EQ(val, "*"))
2355
- rb_hash_aset(hp->env, g_path_info, val);
2440
+ rb_hash_aset(hp->env, g_path_info, val);
2356
2441
  }
2357
- #line 342 "pitchfork_http.rl"
2442
+ #line 367 "pitchfork_http.rl"
2358
2443
  {
2444
+ VALUE str;
2445
+
2359
2446
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
2360
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
2447
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
2448
+
2449
+ if (STR_CSTR_EQ(str, "*")) {
2450
+ rb_hash_aset(hp->env, g_path_info, str);
2451
+ }
2361
2452
  }
2362
2453
  goto st73;
2363
2454
  tr126:
2364
- #line 355 "pitchfork_http.rl"
2455
+ #line 381 "pitchfork_http.rl"
2365
2456
  {MARK(start.query, p); }
2366
- #line 356 "pitchfork_http.rl"
2457
+ #line 382 "pitchfork_http.rl"
2367
2458
  {
2368
2459
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
2369
2460
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
2370
2461
  }
2371
- #line 342 "pitchfork_http.rl"
2462
+ #line 367 "pitchfork_http.rl"
2372
2463
  {
2464
+ VALUE str;
2465
+
2373
2466
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
2374
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
2467
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
2468
+
2469
+ if (STR_CSTR_EQ(str, "*")) {
2470
+ rb_hash_aset(hp->env, g_path_info, str);
2471
+ }
2375
2472
  }
2376
2473
  goto st73;
2377
2474
  tr131:
2378
- #line 356 "pitchfork_http.rl"
2475
+ #line 382 "pitchfork_http.rl"
2379
2476
  {
2380
2477
  VALIDATE_MAX_URI_LENGTH(LEN(start.query, p), QUERY_STRING);
2381
2478
  rb_hash_aset(hp->env, g_query_string, STR_NEW(start.query, p));
2382
2479
  }
2383
- #line 342 "pitchfork_http.rl"
2480
+ #line 367 "pitchfork_http.rl"
2384
2481
  {
2482
+ VALUE str;
2483
+
2385
2484
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_URI);
2386
- rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
2485
+ str = rb_hash_aset(hp->env, g_request_uri, STR_NEW(mark, p));
2486
+
2487
+ if (STR_CSTR_EQ(str, "*")) {
2488
+ rb_hash_aset(hp->env, g_path_info, str);
2489
+ }
2387
2490
  }
2388
2491
  goto st73;
2389
2492
  st73:
2390
2493
  if ( ++p == pe )
2391
2494
  goto _test_eof73;
2392
2495
  case 73:
2393
- #line 2394 "pitchfork_http.c"
2496
+ #line 2497 "pitchfork_http.c"
2394
2497
  switch( (*p) ) {
2395
- case 10: goto tr108;
2396
- case 13: goto tr109;
2397
- case 32: goto tr42;
2498
+ case 10: goto tr107;
2499
+ case 13: goto tr108;
2500
+ case 32: goto tr41;
2398
2501
  case 35: goto st0;
2399
2502
  case 37: goto tr110;
2400
2503
  case 127: goto st0;
2401
2504
  }
2402
- if ( 0 <= (*p) && (*p) <= 31 )
2505
+ if ( (*p) <= 31 )
2403
2506
  goto st0;
2404
- goto tr107;
2405
- tr107:
2406
- #line 328 "pitchfork_http.rl"
2507
+ goto tr109;
2508
+ tr109:
2509
+ #line 353 "pitchfork_http.rl"
2407
2510
  {MARK(mark, p); }
2408
2511
  goto st74;
2409
2512
  st74:
2410
2513
  if ( ++p == pe )
2411
2514
  goto _test_eof74;
2412
2515
  case 74:
2413
- #line 2414 "pitchfork_http.c"
2516
+ #line 2517 "pitchfork_http.c"
2414
2517
  switch( (*p) ) {
2415
- case 10: goto tr112;
2416
- case 13: goto tr113;
2417
- case 32: goto tr45;
2518
+ case 10: goto tr111;
2519
+ case 13: goto tr112;
2520
+ case 32: goto tr44;
2418
2521
  case 35: goto st0;
2419
2522
  case 37: goto st75;
2420
2523
  case 127: goto st0;
2421
2524
  }
2422
- if ( 0 <= (*p) && (*p) <= 31 )
2525
+ if ( (*p) <= 31 )
2423
2526
  goto st0;
2424
2527
  goto st74;
2425
2528
  tr110:
2426
- #line 328 "pitchfork_http.rl"
2529
+ #line 353 "pitchfork_http.rl"
2427
2530
  {MARK(mark, p); }
2428
2531
  goto st75;
2429
2532
  st75:
2430
2533
  if ( ++p == pe )
2431
2534
  goto _test_eof75;
2432
2535
  case 75:
2433
- #line 2434 "pitchfork_http.c"
2536
+ #line 2537 "pitchfork_http.c"
2434
2537
  if ( (*p) < 65 ) {
2435
2538
  if ( 48 <= (*p) && (*p) <= 57 )
2436
2539
  goto st76;
@@ -2454,30 +2557,30 @@ case 76:
2454
2557
  goto st74;
2455
2558
  goto st0;
2456
2559
  tr102:
2457
- #line 328 "pitchfork_http.rl"
2560
+ #line 353 "pitchfork_http.rl"
2458
2561
  {MARK(mark, p); }
2459
2562
  goto st77;
2460
2563
  tr147:
2461
- #line 341 "pitchfork_http.rl"
2564
+ #line 366 "pitchfork_http.rl"
2462
2565
  { rb_hash_aset(hp->env, g_http_host, STR_NEW(mark, p)); }
2463
- #line 328 "pitchfork_http.rl"
2566
+ #line 353 "pitchfork_http.rl"
2464
2567
  {MARK(mark, p); }
2465
2568
  goto st77;
2466
2569
  st77:
2467
2570
  if ( ++p == pe )
2468
2571
  goto _test_eof77;
2469
2572
  case 77:
2470
- #line 2471 "pitchfork_http.c"
2573
+ #line 2574 "pitchfork_http.c"
2471
2574
  switch( (*p) ) {
2472
- case 10: goto tr117;
2473
- case 13: goto tr118;
2474
- case 32: goto tr49;
2575
+ case 10: goto tr116;
2576
+ case 13: goto tr117;
2577
+ case 32: goto tr48;
2475
2578
  case 35: goto tr119;
2476
2579
  case 37: goto st78;
2477
2580
  case 63: goto tr121;
2478
2581
  case 127: goto st0;
2479
2582
  }
2480
- if ( 0 <= (*p) && (*p) <= 31 )
2583
+ if ( (*p) <= 31 )
2481
2584
  goto st0;
2482
2585
  goto st77;
2483
2586
  st78:
@@ -2507,63 +2610,61 @@ case 79:
2507
2610
  goto st77;
2508
2611
  goto st0;
2509
2612
  tr121:
2510
- #line 361 "pitchfork_http.rl"
2613
+ #line 387 "pitchfork_http.rl"
2511
2614
  {
2512
2615
  VALUE val;
2513
2616
 
2514
2617
  VALIDATE_MAX_URI_LENGTH(LEN(mark, p), REQUEST_PATH);
2515
2618
  val = rb_hash_aset(hp->env, g_request_path, STR_NEW(mark, p));
2516
2619
 
2517
- /* rack says PATH_INFO must start with "/" or be empty */
2518
- if (!STR_CSTR_EQ(val, "*"))
2519
- rb_hash_aset(hp->env, g_path_info, val);
2620
+ rb_hash_aset(hp->env, g_path_info, val);
2520
2621
  }
2521
2622
  goto st80;
2522
2623
  st80:
2523
2624
  if ( ++p == pe )
2524
2625
  goto _test_eof80;
2525
2626
  case 80:
2526
- #line 2527 "pitchfork_http.c"
2627
+ #line 2628 "pitchfork_http.c"
2527
2628
  switch( (*p) ) {
2528
- case 10: goto tr124;
2529
- case 13: goto tr125;
2530
- case 32: goto tr55;
2629
+ case 10: goto tr123;
2630
+ case 13: goto tr124;
2631
+ case 32: goto tr54;
2531
2632
  case 35: goto tr126;
2532
2633
  case 37: goto tr127;
2533
2634
  case 127: goto st0;
2534
2635
  }
2535
- if ( 0 <= (*p) && (*p) <= 31 )
2636
+ if ( (*p) <= 31 )
2536
2637
  goto st0;
2537
- goto tr123;
2538
- tr123:
2539
- #line 355 "pitchfork_http.rl"
2638
+ goto tr125;
2639
+ tr125:
2640
+ #line 381 "pitchfork_http.rl"
2540
2641
  {MARK(start.query, p); }
2541
2642
  goto st81;
2542
2643
  st81:
2543
2644
  if ( ++p == pe )
2544
2645
  goto _test_eof81;
2545
2646
  case 81:
2546
- #line 2547 "pitchfork_http.c"
2647
+ #line 2648 "pitchfork_http.c"
2547
2648
  switch( (*p) ) {
2548
- case 10: goto tr129;
2549
- case 13: goto tr130;
2550
- case 32: goto tr59;
2649
+ case 10: goto tr128;
2650
+ case 13: goto tr129;
2651
+ case 32: goto tr58;
2551
2652
  case 35: goto tr131;
2552
2653
  case 37: goto st82;
2553
2654
  case 127: goto st0;
2554
2655
  }
2555
- if ( 0 <= (*p) && (*p) <= 31 )
2656
+ if ( (*p) <= 31 )
2556
2657
  goto st0;
2557
2658
  goto st81;
2558
2659
  tr127:
2559
- #line 355 "pitchfork_http.rl"
2660
+ #line 381 "pitchfork_http.rl"
2560
2661
  {MARK(start.query, p); }
2561
2662
  goto st82;
2562
2663
  st82:
2563
2664
  if ( ++p == pe )
2564
2665
  goto _test_eof82;
2565
2666
  case 82:
2566
- #line 2567 "pitchfork_http.c"
2667
+ #line 2668 "pitchfork_http.c"
2567
2668
  if ( (*p) < 65 ) {
2568
2669
  if ( 48 <= (*p) && (*p) <= 57 )
2569
2670
  goto st83;
@@ -2587,58 +2688,58 @@ case 83:
2587
2688
  goto st81;
2588
2689
  goto st0;
2589
2690
  tr103:
2590
- #line 328 "pitchfork_http.rl"
2691
+ #line 353 "pitchfork_http.rl"
2591
2692
  {MARK(mark, p); }
2592
- #line 332 "pitchfork_http.rl"
2693
+ #line 357 "pitchfork_http.rl"
2593
2694
  { downcase_char(deconst(p)); }
2594
2695
  goto st84;
2595
2696
  st84:
2596
2697
  if ( ++p == pe )
2597
2698
  goto _test_eof84;
2598
2699
  case 84:
2599
- #line 2600 "pitchfork_http.c"
2700
+ #line 2701 "pitchfork_http.c"
2600
2701
  switch( (*p) ) {
2601
2702
  case 84: goto tr134;
2602
2703
  case 116: goto tr134;
2603
2704
  }
2604
2705
  goto st0;
2605
2706
  tr134:
2606
- #line 332 "pitchfork_http.rl"
2707
+ #line 357 "pitchfork_http.rl"
2607
2708
  { downcase_char(deconst(p)); }
2608
2709
  goto st85;
2609
2710
  st85:
2610
2711
  if ( ++p == pe )
2611
2712
  goto _test_eof85;
2612
2713
  case 85:
2613
- #line 2614 "pitchfork_http.c"
2714
+ #line 2715 "pitchfork_http.c"
2614
2715
  switch( (*p) ) {
2615
2716
  case 84: goto tr135;
2616
2717
  case 116: goto tr135;
2617
2718
  }
2618
2719
  goto st0;
2619
2720
  tr135:
2620
- #line 332 "pitchfork_http.rl"
2721
+ #line 357 "pitchfork_http.rl"
2621
2722
  { downcase_char(deconst(p)); }
2622
2723
  goto st86;
2623
2724
  st86:
2624
2725
  if ( ++p == pe )
2625
2726
  goto _test_eof86;
2626
2727
  case 86:
2627
- #line 2628 "pitchfork_http.c"
2728
+ #line 2729 "pitchfork_http.c"
2628
2729
  switch( (*p) ) {
2629
2730
  case 80: goto tr136;
2630
2731
  case 112: goto tr136;
2631
2732
  }
2632
2733
  goto st0;
2633
2734
  tr136:
2634
- #line 332 "pitchfork_http.rl"
2735
+ #line 357 "pitchfork_http.rl"
2635
2736
  { downcase_char(deconst(p)); }
2636
2737
  goto st87;
2637
2738
  st87:
2638
2739
  if ( ++p == pe )
2639
2740
  goto _test_eof87;
2640
2741
  case 87:
2641
- #line 2642 "pitchfork_http.c"
2742
+ #line 2743 "pitchfork_http.c"
2642
2743
  switch( (*p) ) {
2643
2744
  case 58: goto tr137;
2644
2745
  case 83: goto tr138;
@@ -2646,7 +2747,7 @@ case 87:
2646
2747
  }
2647
2748
  goto st0;
2648
2749
  tr137:
2649
- #line 338 "pitchfork_http.rl"
2750
+ #line 363 "pitchfork_http.rl"
2650
2751
  {
2651
2752
  rb_hash_aset(hp->env, g_rack_url_scheme, STR_NEW(mark, p));
2652
2753
  }
@@ -2655,7 +2756,7 @@ st88:
2655
2756
  if ( ++p == pe )
2656
2757
  goto _test_eof88;
2657
2758
  case 88:
2658
- #line 2659 "pitchfork_http.c"
2759
+ #line 2760 "pitchfork_http.c"
2659
2760
  if ( (*p) == 47 )
2660
2761
  goto st89;
2661
2762
  goto st0;
@@ -2682,7 +2783,7 @@ case 90:
2682
2783
  if ( (*p) > 32 ) {
2683
2784
  if ( 34 <= (*p) && (*p) <= 35 )
2684
2785
  goto st0;
2685
- } else if ( (*p) >= 0 )
2786
+ } else
2686
2787
  goto st0;
2687
2788
  } else if ( (*p) > 57 ) {
2688
2789
  if ( (*p) < 65 ) {
@@ -2708,7 +2809,7 @@ case 91:
2708
2809
  case 127: goto st0;
2709
2810
  }
2710
2811
  if ( (*p) < 34 ) {
2711
- if ( 0 <= (*p) && (*p) <= 32 )
2812
+ if ( (*p) <= 32 )
2712
2813
  goto st0;
2713
2814
  } else if ( (*p) > 35 ) {
2714
2815
  if ( 62 <= (*p) && (*p) <= 63 )
@@ -2743,14 +2844,14 @@ case 93:
2743
2844
  goto st91;
2744
2845
  goto st0;
2745
2846
  tr143:
2746
- #line 328 "pitchfork_http.rl"
2847
+ #line 353 "pitchfork_http.rl"
2747
2848
  {MARK(mark, p); }
2748
2849
  goto st94;
2749
2850
  st94:
2750
2851
  if ( ++p == pe )
2751
2852
  goto _test_eof94;
2752
2853
  case 94:
2753
- #line 2754 "pitchfork_http.c"
2854
+ #line 2855 "pitchfork_http.c"
2754
2855
  switch( (*p) ) {
2755
2856
  case 37: goto st92;
2756
2857
  case 47: goto tr147;
@@ -2764,7 +2865,7 @@ case 94:
2764
2865
  if ( (*p) > 32 ) {
2765
2866
  if ( 34 <= (*p) && (*p) <= 35 )
2766
2867
  goto st0;
2767
- } else if ( (*p) >= 0 )
2868
+ } else
2768
2869
  goto st0;
2769
2870
  } else if ( (*p) > 57 ) {
2770
2871
  if ( (*p) < 65 ) {
@@ -2790,7 +2891,7 @@ case 95:
2790
2891
  case 127: goto st0;
2791
2892
  }
2792
2893
  if ( (*p) < 34 ) {
2793
- if ( 0 <= (*p) && (*p) <= 32 )
2894
+ if ( (*p) <= 32 )
2794
2895
  goto st0;
2795
2896
  } else if ( (*p) > 35 ) {
2796
2897
  if ( (*p) > 57 ) {
@@ -2802,14 +2903,14 @@ case 95:
2802
2903
  goto st0;
2803
2904
  goto st91;
2804
2905
  tr144:
2805
- #line 328 "pitchfork_http.rl"
2906
+ #line 353 "pitchfork_http.rl"
2806
2907
  {MARK(mark, p); }
2807
2908
  goto st96;
2808
2909
  st96:
2809
2910
  if ( ++p == pe )
2810
2911
  goto _test_eof96;
2811
2912
  case 96:
2812
- #line 2813 "pitchfork_http.c"
2913
+ #line 2914 "pitchfork_http.c"
2813
2914
  switch( (*p) ) {
2814
2915
  case 37: goto st92;
2815
2916
  case 47: goto st0;
@@ -2821,7 +2922,7 @@ case 96:
2821
2922
  if ( (*p) > 32 ) {
2822
2923
  if ( 34 <= (*p) && (*p) <= 35 )
2823
2924
  goto st0;
2824
- } else if ( (*p) >= 0 )
2925
+ } else
2825
2926
  goto st0;
2826
2927
  } else if ( (*p) > 58 ) {
2827
2928
  if ( (*p) < 65 ) {
@@ -2851,7 +2952,7 @@ case 97:
2851
2952
  if ( (*p) > 32 ) {
2852
2953
  if ( 34 <= (*p) && (*p) <= 35 )
2853
2954
  goto st0;
2854
- } else if ( (*p) >= 0 )
2955
+ } else
2855
2956
  goto st0;
2856
2957
  } else if ( (*p) > 58 ) {
2857
2958
  if ( (*p) < 65 ) {
@@ -2878,7 +2979,7 @@ case 98:
2878
2979
  case 127: goto st0;
2879
2980
  }
2880
2981
  if ( (*p) < 34 ) {
2881
- if ( 0 <= (*p) && (*p) <= 32 )
2982
+ if ( (*p) <= 32 )
2882
2983
  goto st0;
2883
2984
  } else if ( (*p) > 35 ) {
2884
2985
  if ( 62 <= (*p) && (*p) <= 63 )
@@ -2887,14 +2988,14 @@ case 98:
2887
2988
  goto st0;
2888
2989
  goto st91;
2889
2990
  tr138:
2890
- #line 332 "pitchfork_http.rl"
2991
+ #line 357 "pitchfork_http.rl"
2891
2992
  { downcase_char(deconst(p)); }
2892
2993
  goto st99;
2893
2994
  st99:
2894
2995
  if ( ++p == pe )
2895
2996
  goto _test_eof99;
2896
2997
  case 99:
2897
- #line 2898 "pitchfork_http.c"
2998
+ #line 2999 "pitchfork_http.c"
2898
2999
  if ( (*p) == 58 )
2899
3000
  goto tr137;
2900
3001
  goto st0;
@@ -2914,7 +3015,7 @@ case 100:
2914
3015
  goto tr152;
2915
3016
  goto st0;
2916
3017
  tr151:
2917
- #line 371 "pitchfork_http.rl"
3018
+ #line 395 "pitchfork_http.rl"
2918
3019
  {
2919
3020
  hp->len.chunk = step_incr(hp->len.chunk, (*p), 16);
2920
3021
  if (hp->len.chunk < 0)
@@ -2925,7 +3026,7 @@ st101:
2925
3026
  if ( ++p == pe )
2926
3027
  goto _test_eof101;
2927
3028
  case 101:
2928
- #line 2929 "pitchfork_http.c"
3029
+ #line 3030 "pitchfork_http.c"
2929
3030
  switch( (*p) ) {
2930
3031
  case 10: goto tr153;
2931
3032
  case 13: goto st102;
@@ -2942,9 +3043,10 @@ case 101:
2942
3043
  goto tr152;
2943
3044
  goto st0;
2944
3045
  tr153:
2945
- #line 400 "pitchfork_http.rl"
3046
+ #line 424 "pitchfork_http.rl"
2946
3047
  {
2947
3048
  HP_FL_SET(hp, INTRAILER);
3049
+ RB_OBJ_WRITE(self, &hp->cont, Qfalse);
2948
3050
  cs = http_parser_en_Trailers;
2949
3051
  ++p;
2950
3052
  assert(p <= pe && "buffer overflow after chunked body");
@@ -2955,7 +3057,7 @@ st123:
2955
3057
  if ( ++p == pe )
2956
3058
  goto _test_eof123;
2957
3059
  case 123:
2958
- #line 2959 "pitchfork_http.c"
3060
+ #line 3061 "pitchfork_http.c"
2959
3061
  goto st0;
2960
3062
  st102:
2961
3063
  if ( ++p == pe )
@@ -2965,7 +3067,7 @@ case 102:
2965
3067
  goto tr153;
2966
3068
  goto st0;
2967
3069
  tr152:
2968
- #line 371 "pitchfork_http.rl"
3070
+ #line 395 "pitchfork_http.rl"
2969
3071
  {
2970
3072
  hp->len.chunk = step_incr(hp->len.chunk, (*p), 16);
2971
3073
  if (hp->len.chunk < 0)
@@ -2976,7 +3078,7 @@ st103:
2976
3078
  if ( ++p == pe )
2977
3079
  goto _test_eof103;
2978
3080
  case 103:
2979
- #line 2980 "pitchfork_http.c"
3081
+ #line 3082 "pitchfork_http.c"
2980
3082
  switch( (*p) ) {
2981
3083
  case 10: goto st104;
2982
3084
  case 13: goto st107;
@@ -2997,7 +3099,7 @@ st104:
2997
3099
  case 104:
2998
3100
  goto tr159;
2999
3101
  tr159:
3000
- #line 408 "pitchfork_http.rl"
3102
+ #line 433 "pitchfork_http.rl"
3001
3103
  {
3002
3104
  skip_chunk_data_hack: {
3003
3105
  size_t nr = MIN((size_t)hp->len.chunk, REMAINING);
@@ -3019,7 +3121,7 @@ st105:
3019
3121
  if ( ++p == pe )
3020
3122
  goto _test_eof105;
3021
3123
  case 105:
3022
- #line 3023 "pitchfork_http.c"
3124
+ #line 3125 "pitchfork_http.c"
3023
3125
  switch( (*p) ) {
3024
3126
  case 10: goto st100;
3025
3127
  case 13: goto st106;
@@ -3225,31 +3327,31 @@ case 113:
3225
3327
  } else
3226
3328
  goto st113;
3227
3329
  goto st0;
3228
- tr172:
3229
- #line 334 "pitchfork_http.rl"
3330
+ tr171:
3331
+ #line 359 "pitchfork_http.rl"
3230
3332
  { MARK(mark, p); }
3231
- #line 336 "pitchfork_http.rl"
3333
+ #line 361 "pitchfork_http.rl"
3232
3334
  { write_cont_value(hp, buffer, p); }
3233
3335
  goto st114;
3234
- tr175:
3235
- #line 336 "pitchfork_http.rl"
3336
+ tr176:
3337
+ #line 361 "pitchfork_http.rl"
3236
3338
  { write_cont_value(hp, buffer, p); }
3237
3339
  goto st114;
3238
- tr182:
3239
- #line 334 "pitchfork_http.rl"
3340
+ tr181:
3341
+ #line 359 "pitchfork_http.rl"
3240
3342
  { MARK(mark, p); }
3241
- #line 335 "pitchfork_http.rl"
3343
+ #line 360 "pitchfork_http.rl"
3242
3344
  { write_value(self, hp, buffer, p); }
3243
3345
  goto st114;
3244
3346
  tr185:
3245
- #line 335 "pitchfork_http.rl"
3347
+ #line 360 "pitchfork_http.rl"
3246
3348
  { write_value(self, hp, buffer, p); }
3247
3349
  goto st114;
3248
3350
  st114:
3249
3351
  if ( ++p == pe )
3250
3352
  goto _test_eof114;
3251
3353
  case 114:
3252
- #line 3253 "pitchfork_http.c"
3354
+ #line 3355 "pitchfork_http.c"
3253
3355
  switch( (*p) ) {
3254
3356
  case 9: goto st115;
3255
3357
  case 10: goto tr167;
@@ -3277,75 +3379,75 @@ case 114:
3277
3379
  } else
3278
3380
  goto tr169;
3279
3381
  goto st0;
3280
- tr171:
3281
- #line 334 "pitchfork_http.rl"
3382
+ tr170:
3383
+ #line 359 "pitchfork_http.rl"
3282
3384
  { MARK(mark, p); }
3283
3385
  goto st115;
3284
3386
  st115:
3285
3387
  if ( ++p == pe )
3286
3388
  goto _test_eof115;
3287
3389
  case 115:
3288
- #line 3289 "pitchfork_http.c"
3390
+ #line 3391 "pitchfork_http.c"
3289
3391
  switch( (*p) ) {
3290
- case 9: goto tr171;
3291
- case 10: goto tr172;
3292
- case 13: goto tr173;
3293
- case 32: goto tr171;
3392
+ case 9: goto tr170;
3393
+ case 10: goto tr171;
3394
+ case 13: goto tr172;
3395
+ case 32: goto tr170;
3294
3396
  case 127: goto st0;
3295
3397
  }
3296
- if ( 0 <= (*p) && (*p) <= 31 )
3398
+ if ( (*p) <= 31 )
3297
3399
  goto st0;
3298
- goto tr170;
3299
- tr170:
3300
- #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"
3301
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); }
3302
3420
  goto st116;
3303
3421
  st116:
3304
3422
  if ( ++p == pe )
3305
3423
  goto _test_eof116;
3306
3424
  case 116:
3307
- #line 3308 "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"
3308
3438
  switch( (*p) ) {
3309
- case 10: goto tr175;
3310
- case 13: goto tr176;
3439
+ case 10: goto tr176;
3440
+ case 13: goto tr177;
3311
3441
  case 127: goto st0;
3312
3442
  }
3313
3443
  if ( (*p) > 8 ) {
3314
3444
  if ( 11 <= (*p) && (*p) <= 31 )
3315
3445
  goto st0;
3316
- } else if ( (*p) >= 0 )
3446
+ } else
3317
3447
  goto st0;
3318
- goto st116;
3319
- tr173:
3320
- #line 334 "pitchfork_http.rl"
3321
- { MARK(mark, p); }
3322
- #line 336 "pitchfork_http.rl"
3323
- { write_cont_value(hp, buffer, p); }
3324
- goto st117;
3325
- tr176:
3326
- #line 336 "pitchfork_http.rl"
3327
- { write_cont_value(hp, buffer, p); }
3328
- goto st117;
3329
- tr183:
3330
- #line 334 "pitchfork_http.rl"
3331
- { MARK(mark, p); }
3332
- #line 335 "pitchfork_http.rl"
3333
- { write_value(self, hp, buffer, p); }
3334
- goto st117;
3335
- tr186:
3336
- #line 335 "pitchfork_http.rl"
3337
- { write_value(self, hp, buffer, p); }
3338
3448
  goto st117;
3339
- st117:
3340
- if ( ++p == pe )
3341
- goto _test_eof117;
3342
- case 117:
3343
- #line 3344 "pitchfork_http.c"
3344
- if ( (*p) == 10 )
3345
- goto st114;
3346
- goto st0;
3347
3449
  tr167:
3348
- #line 395 "pitchfork_http.rl"
3450
+ #line 419 "pitchfork_http.rl"
3349
3451
  {
3350
3452
  cs = http_parser_first_final;
3351
3453
  goto post_exec;
@@ -3355,7 +3457,7 @@ st124:
3355
3457
  if ( ++p == pe )
3356
3458
  goto _test_eof124;
3357
3459
  case 124:
3358
- #line 3359 "pitchfork_http.c"
3460
+ #line 3461 "pitchfork_http.c"
3359
3461
  goto st0;
3360
3462
  st118:
3361
3463
  if ( ++p == pe )
@@ -3365,20 +3467,20 @@ case 118:
3365
3467
  goto tr167;
3366
3468
  goto st0;
3367
3469
  tr169:
3368
- #line 330 "pitchfork_http.rl"
3470
+ #line 355 "pitchfork_http.rl"
3369
3471
  { MARK(start.field, p); }
3370
- #line 331 "pitchfork_http.rl"
3371
- { snake_upcase_char(deconst(p)); }
3472
+ #line 356 "pitchfork_http.rl"
3473
+ { upcase_char(deconst(p)); }
3372
3474
  goto st119;
3373
3475
  tr178:
3374
- #line 331 "pitchfork_http.rl"
3375
- { snake_upcase_char(deconst(p)); }
3476
+ #line 356 "pitchfork_http.rl"
3477
+ { upcase_char(deconst(p)); }
3376
3478
  goto st119;
3377
3479
  st119:
3378
3480
  if ( ++p == pe )
3379
3481
  goto _test_eof119;
3380
3482
  case 119:
3381
- #line 3382 "pitchfork_http.c"
3483
+ #line 3484 "pitchfork_http.c"
3382
3484
  switch( (*p) ) {
3383
3485
  case 33: goto tr178;
3384
3486
  case 58: goto tr179;
@@ -3403,38 +3505,38 @@ case 119:
3403
3505
  } else
3404
3506
  goto tr178;
3405
3507
  goto st0;
3406
- tr181:
3407
- #line 334 "pitchfork_http.rl"
3508
+ tr180:
3509
+ #line 359 "pitchfork_http.rl"
3408
3510
  { MARK(mark, p); }
3409
3511
  goto st120;
3410
3512
  tr179:
3411
- #line 333 "pitchfork_http.rl"
3513
+ #line 358 "pitchfork_http.rl"
3412
3514
  { hp->s.field_len = LEN(start.field, p); }
3413
3515
  goto st120;
3414
3516
  st120:
3415
3517
  if ( ++p == pe )
3416
3518
  goto _test_eof120;
3417
3519
  case 120:
3418
- #line 3419 "pitchfork_http.c"
3520
+ #line 3521 "pitchfork_http.c"
3419
3521
  switch( (*p) ) {
3420
- case 9: goto tr181;
3421
- case 10: goto tr182;
3422
- case 13: goto tr183;
3423
- case 32: goto tr181;
3522
+ case 9: goto tr180;
3523
+ case 10: goto tr181;
3524
+ case 13: goto tr182;
3525
+ case 32: goto tr180;
3424
3526
  case 127: goto st0;
3425
3527
  }
3426
- if ( 0 <= (*p) && (*p) <= 31 )
3528
+ if ( (*p) <= 31 )
3427
3529
  goto st0;
3428
- goto tr180;
3429
- tr180:
3430
- #line 334 "pitchfork_http.rl"
3530
+ goto tr183;
3531
+ tr183:
3532
+ #line 359 "pitchfork_http.rl"
3431
3533
  { MARK(mark, p); }
3432
3534
  goto st121;
3433
3535
  st121:
3434
3536
  if ( ++p == pe )
3435
3537
  goto _test_eof121;
3436
3538
  case 121:
3437
- #line 3438 "pitchfork_http.c"
3539
+ #line 3540 "pitchfork_http.c"
3438
3540
  switch( (*p) ) {
3439
3541
  case 10: goto tr185;
3440
3542
  case 13: goto tr186;
@@ -3443,7 +3545,7 @@ case 121:
3443
3545
  if ( (*p) > 8 ) {
3444
3546
  if ( 11 <= (*p) && (*p) <= 31 )
3445
3547
  goto st0;
3446
- } else if ( (*p) >= 0 )
3548
+ } else
3447
3549
  goto st0;
3448
3550
  goto st121;
3449
3551
  }
@@ -3575,7 +3677,7 @@ case 121:
3575
3677
  _out: {}
3576
3678
  }
3577
3679
 
3578
- #line 469 "pitchfork_http.rl"
3680
+ #line 494 "pitchfork_http.rl"
3579
3681
  post_exec: /* "_out:" also goes here */
3580
3682
  if (hp->cs != http_parser_error)
3581
3683
  hp->cs = cs;
@@ -4007,7 +4109,8 @@ static VALUE HttpParser_filter_body(VALUE self, VALUE dst, VALUE src)
4007
4109
  if (HP_FL_TEST(hp, CHUNKED)) {
4008
4110
  if (!chunked_eof(hp)) {
4009
4111
  rb_str_modify(dst);
4010
- 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 */
4011
4114
 
4012
4115
  hp->s.dest_offset = 0;
4013
4116
  RB_OBJ_WRITE(self, &hp->cont, dst);
@@ -4018,8 +4121,12 @@ static VALUE HttpParser_filter_body(VALUE self, VALUE dst, VALUE src)
4018
4121
 
4019
4122
  assert(hp->s.dest_offset <= hp->offset &&
4020
4123
  "destination buffer overflow");
4021
- 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
+ */
4022
4128
  rb_str_set_len(dst, hp->s.dest_offset);
4129
+ advance_str(src, hp->offset);
4023
4130
 
4024
4131
  if (RSTRING_LEN(dst) == 0 && chunked_eof(hp)) {
4025
4132
  assert(hp->len.chunk == 0 && "chunk at EOF but more to parse");