http11: minor cleanups in return types
[unicorn.git] / ext / unicorn / http11 / http11_parser.h
blob30aff6a949647c0411e2cd1e979ffebb656bdee6
2 #line 1 "http11_parser.rl"
3 /**
4 * Copyright (c) 2005 Zed A. Shaw
5 * You can redistribute it and/or modify it under the same terms as Ruby.
6 */
7 #ifndef http11_parser_h
8 #define http11_parser_h
10 #include <sys/types.h>
12 static void http_field(void *data, const char *field,
13 size_t flen, const char *value, size_t vlen);
14 static void request_method(void *data, const char *at, size_t length);
15 static void request_uri(void *data, const char *at, size_t length);
16 static void fragment(void *data, const char *at, size_t length);
17 static void request_path(void *data, const char *at, size_t length);
18 static void query_string(void *data, const char *at, size_t length);
19 static void http_version(void *data, const char *at, size_t length);
20 static void header_done(void *data, const char *at, size_t length);
22 typedef struct http_parser {
23 int cs;
24 size_t body_start;
25 size_t nread;
26 size_t mark;
27 size_t field_start;
28 size_t field_len;
29 size_t query_start;
31 void *data;
32 } http_parser;
34 static int http_parser_has_error(http_parser *parser);
35 static int http_parser_is_finished(http_parser *parser);
38 * capitalizes all lower-case ASCII characters,
39 * converts dashes to underscores.
41 static void snake_upcase_char(char *c)
43 if (*c >= 'a' && *c <= 'z')
44 *c &= ~0x20;
45 else if (*c == '-')
46 *c = '_';
49 static void downcase_char(char *c)
51 if (*c >= 'A' && *c <= 'Z')
52 *c |= 0x20;
55 #define LEN(AT, FPC) (FPC - buffer - parser->AT)
56 #define MARK(M,FPC) (parser->M = (FPC) - buffer)
57 #define PTR_TO(F) (buffer + parser->F)
59 /** Machine **/
62 #line 105 "http11_parser.rl"
65 /** Data **/
67 #line 68 "http11_parser.h"
68 static const int http_parser_start = 1;
69 static const int http_parser_first_final = 63;
70 static const int http_parser_error = 0;
72 static const int http_parser_en_main = 1;
75 #line 109 "http11_parser.rl"
77 static void http_parser_init(http_parser *parser) {
78 int cs = 0;
79 memset(parser, 0, sizeof(*parser));
81 #line 82 "http11_parser.h"
83 cs = http_parser_start;
86 #line 114 "http11_parser.rl"
87 parser->cs = cs;
90 /** exec **/
91 static void http_parser_execute(
92 http_parser *parser, const char *buffer, size_t len)
94 const char *p, *pe;
95 int cs = parser->cs;
96 size_t off = parser->nread;
98 assert(off <= len && "offset past end of buffer");
100 p = buffer+off;
101 pe = buffer+len;
103 assert(*pe == '\0' && "pointer does not end on NUL");
104 assert(pe - p == len - off && "pointers aren't same distance");
107 #line 108 "http11_parser.h"
109 if ( p == pe )
110 goto _test_eof;
111 switch ( cs )
113 case 1:
114 switch( (*p) ) {
115 case 36: goto tr0;
116 case 95: goto tr0;
118 if ( (*p) < 48 ) {
119 if ( 45 <= (*p) && (*p) <= 46 )
120 goto tr0;
121 } else if ( (*p) > 57 ) {
122 if ( 65 <= (*p) && (*p) <= 90 )
123 goto tr0;
124 } else
125 goto tr0;
126 goto st0;
127 st0:
128 cs = 0;
129 goto _out;
130 tr0:
131 #line 62 "http11_parser.rl"
132 {MARK(mark, p); }
133 goto st2;
134 st2:
135 if ( ++p == pe )
136 goto _test_eof2;
137 case 2:
138 #line 139 "http11_parser.h"
139 switch( (*p) ) {
140 case 32: goto tr2;
141 case 36: goto st44;
142 case 95: goto st44;
144 if ( (*p) < 48 ) {
145 if ( 45 <= (*p) && (*p) <= 46 )
146 goto st44;
147 } else if ( (*p) > 57 ) {
148 if ( 65 <= (*p) && (*p) <= 90 )
149 goto st44;
150 } else
151 goto st44;
152 goto st0;
153 tr2:
154 #line 75 "http11_parser.rl"
156 request_method(parser->data, PTR_TO(mark), LEN(mark, p));
158 goto st3;
159 st3:
160 if ( ++p == pe )
161 goto _test_eof3;
162 case 3:
163 #line 164 "http11_parser.h"
164 switch( (*p) ) {
165 case 42: goto tr4;
166 case 47: goto tr5;
167 case 72: goto tr6;
168 case 104: goto tr6;
170 goto st0;
171 tr4:
172 #line 62 "http11_parser.rl"
173 {MARK(mark, p); }
174 goto st4;
175 st4:
176 if ( ++p == pe )
177 goto _test_eof4;
178 case 4:
179 #line 180 "http11_parser.h"
180 switch( (*p) ) {
181 case 32: goto tr7;
182 case 35: goto tr8;
184 goto st0;
185 tr7:
186 #line 78 "http11_parser.rl"
188 request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
190 goto st5;
191 tr30:
192 #line 62 "http11_parser.rl"
193 {MARK(mark, p); }
194 #line 81 "http11_parser.rl"
196 fragment(parser->data, PTR_TO(mark), LEN(mark, p));
198 goto st5;
199 tr33:
200 #line 81 "http11_parser.rl"
202 fragment(parser->data, PTR_TO(mark), LEN(mark, p));
204 goto st5;
205 tr37:
206 #line 94 "http11_parser.rl"
208 request_path(parser->data, PTR_TO(mark), LEN(mark,p));
210 #line 78 "http11_parser.rl"
212 request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
214 goto st5;
215 tr48:
216 #line 85 "http11_parser.rl"
217 {MARK(query_start, p); }
218 #line 86 "http11_parser.rl"
220 query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
222 #line 78 "http11_parser.rl"
224 request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
226 goto st5;
227 tr52:
228 #line 86 "http11_parser.rl"
230 query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
232 #line 78 "http11_parser.rl"
234 request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
236 goto st5;
237 st5:
238 if ( ++p == pe )
239 goto _test_eof5;
240 case 5:
241 #line 242 "http11_parser.h"
242 if ( (*p) == 72 )
243 goto tr9;
244 goto st0;
245 tr9:
246 #line 62 "http11_parser.rl"
247 {MARK(mark, p); }
248 goto st6;
249 st6:
250 if ( ++p == pe )
251 goto _test_eof6;
252 case 6:
253 #line 254 "http11_parser.h"
254 if ( (*p) == 84 )
255 goto st7;
256 goto st0;
257 st7:
258 if ( ++p == pe )
259 goto _test_eof7;
260 case 7:
261 if ( (*p) == 84 )
262 goto st8;
263 goto st0;
264 st8:
265 if ( ++p == pe )
266 goto _test_eof8;
267 case 8:
268 if ( (*p) == 80 )
269 goto st9;
270 goto st0;
271 st9:
272 if ( ++p == pe )
273 goto _test_eof9;
274 case 9:
275 if ( (*p) == 47 )
276 goto st10;
277 goto st0;
278 st10:
279 if ( ++p == pe )
280 goto _test_eof10;
281 case 10:
282 if ( 48 <= (*p) && (*p) <= 57 )
283 goto st11;
284 goto st0;
285 st11:
286 if ( ++p == pe )
287 goto _test_eof11;
288 case 11:
289 if ( (*p) == 46 )
290 goto st12;
291 if ( 48 <= (*p) && (*p) <= 57 )
292 goto st11;
293 goto st0;
294 st12:
295 if ( ++p == pe )
296 goto _test_eof12;
297 case 12:
298 if ( 48 <= (*p) && (*p) <= 57 )
299 goto st13;
300 goto st0;
301 st13:
302 if ( ++p == pe )
303 goto _test_eof13;
304 case 13:
305 if ( (*p) == 13 )
306 goto tr17;
307 if ( 48 <= (*p) && (*p) <= 57 )
308 goto st13;
309 goto st0;
310 tr17:
311 #line 90 "http11_parser.rl"
313 http_version(parser->data, PTR_TO(mark), LEN(mark, p));
315 goto st14;
316 tr25:
317 #line 71 "http11_parser.rl"
318 { MARK(mark, p); }
319 #line 72 "http11_parser.rl"
321 http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
323 goto st14;
324 tr28:
325 #line 72 "http11_parser.rl"
327 http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
329 goto st14;
330 st14:
331 if ( ++p == pe )
332 goto _test_eof14;
333 case 14:
334 #line 335 "http11_parser.h"
335 if ( (*p) == 10 )
336 goto st15;
337 goto st0;
338 st15:
339 if ( ++p == pe )
340 goto _test_eof15;
341 case 15:
342 switch( (*p) ) {
343 case 13: goto st16;
344 case 33: goto tr20;
345 case 124: goto tr20;
346 case 126: goto tr20;
348 if ( (*p) < 45 ) {
349 if ( (*p) > 39 ) {
350 if ( 42 <= (*p) && (*p) <= 43 )
351 goto tr20;
352 } else if ( (*p) >= 35 )
353 goto tr20;
354 } else if ( (*p) > 46 ) {
355 if ( (*p) < 65 ) {
356 if ( 48 <= (*p) && (*p) <= 57 )
357 goto tr20;
358 } else if ( (*p) > 90 ) {
359 if ( 94 <= (*p) && (*p) <= 122 )
360 goto tr20;
361 } else
362 goto tr20;
363 } else
364 goto tr20;
365 goto st0;
366 st16:
367 if ( ++p == pe )
368 goto _test_eof16;
369 case 16:
370 if ( (*p) == 10 )
371 goto tr21;
372 goto st0;
373 tr21:
374 #line 98 "http11_parser.rl"
376 parser->body_start = p - buffer + 1;
377 header_done(parser->data, p + 1, pe - p - 1);
378 {p++; cs = 63; goto _out;}
380 goto st63;
381 st63:
382 if ( ++p == pe )
383 goto _test_eof63;
384 case 63:
385 #line 386 "http11_parser.h"
386 goto st0;
387 tr20:
388 #line 64 "http11_parser.rl"
389 { MARK(field_start, p); }
390 #line 65 "http11_parser.rl"
391 { snake_upcase_char((char *)p); }
392 goto st17;
393 tr22:
394 #line 65 "http11_parser.rl"
395 { snake_upcase_char((char *)p); }
396 goto st17;
397 st17:
398 if ( ++p == pe )
399 goto _test_eof17;
400 case 17:
401 #line 402 "http11_parser.h"
402 switch( (*p) ) {
403 case 33: goto tr22;
404 case 58: goto tr23;
405 case 124: goto tr22;
406 case 126: goto tr22;
408 if ( (*p) < 45 ) {
409 if ( (*p) > 39 ) {
410 if ( 42 <= (*p) && (*p) <= 43 )
411 goto tr22;
412 } else if ( (*p) >= 35 )
413 goto tr22;
414 } else if ( (*p) > 46 ) {
415 if ( (*p) < 65 ) {
416 if ( 48 <= (*p) && (*p) <= 57 )
417 goto tr22;
418 } else if ( (*p) > 90 ) {
419 if ( 94 <= (*p) && (*p) <= 122 )
420 goto tr22;
421 } else
422 goto tr22;
423 } else
424 goto tr22;
425 goto st0;
426 tr23:
427 #line 67 "http11_parser.rl"
429 parser->field_len = LEN(field_start, p);
431 goto st18;
432 tr26:
433 #line 71 "http11_parser.rl"
434 { MARK(mark, p); }
435 goto st18;
436 st18:
437 if ( ++p == pe )
438 goto _test_eof18;
439 case 18:
440 #line 441 "http11_parser.h"
441 switch( (*p) ) {
442 case 13: goto tr25;
443 case 32: goto tr26;
445 goto tr24;
446 tr24:
447 #line 71 "http11_parser.rl"
448 { MARK(mark, p); }
449 goto st19;
450 st19:
451 if ( ++p == pe )
452 goto _test_eof19;
453 case 19:
454 #line 455 "http11_parser.h"
455 if ( (*p) == 13 )
456 goto tr28;
457 goto st19;
458 tr8:
459 #line 78 "http11_parser.rl"
461 request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
463 goto st20;
464 tr38:
465 #line 94 "http11_parser.rl"
467 request_path(parser->data, PTR_TO(mark), LEN(mark,p));
469 #line 78 "http11_parser.rl"
471 request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
473 goto st20;
474 tr49:
475 #line 85 "http11_parser.rl"
476 {MARK(query_start, p); }
477 #line 86 "http11_parser.rl"
479 query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
481 #line 78 "http11_parser.rl"
483 request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
485 goto st20;
486 tr53:
487 #line 86 "http11_parser.rl"
489 query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
491 #line 78 "http11_parser.rl"
493 request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
495 goto st20;
496 st20:
497 if ( ++p == pe )
498 goto _test_eof20;
499 case 20:
500 #line 501 "http11_parser.h"
501 switch( (*p) ) {
502 case 32: goto tr30;
503 case 35: goto st0;
504 case 37: goto tr31;
505 case 127: goto st0;
507 if ( 0 <= (*p) && (*p) <= 31 )
508 goto st0;
509 goto tr29;
510 tr29:
511 #line 62 "http11_parser.rl"
512 {MARK(mark, p); }
513 goto st21;
514 st21:
515 if ( ++p == pe )
516 goto _test_eof21;
517 case 21:
518 #line 519 "http11_parser.h"
519 switch( (*p) ) {
520 case 32: goto tr33;
521 case 35: goto st0;
522 case 37: goto st22;
523 case 127: goto st0;
525 if ( 0 <= (*p) && (*p) <= 31 )
526 goto st0;
527 goto st21;
528 tr31:
529 #line 62 "http11_parser.rl"
530 {MARK(mark, p); }
531 goto st22;
532 st22:
533 if ( ++p == pe )
534 goto _test_eof22;
535 case 22:
536 #line 537 "http11_parser.h"
537 if ( (*p) < 65 ) {
538 if ( 48 <= (*p) && (*p) <= 57 )
539 goto st23;
540 } else if ( (*p) > 70 ) {
541 if ( 97 <= (*p) && (*p) <= 102 )
542 goto st23;
543 } else
544 goto st23;
545 goto st0;
546 st23:
547 if ( ++p == pe )
548 goto _test_eof23;
549 case 23:
550 if ( (*p) < 65 ) {
551 if ( 48 <= (*p) && (*p) <= 57 )
552 goto st21;
553 } else if ( (*p) > 70 ) {
554 if ( 97 <= (*p) && (*p) <= 102 )
555 goto st21;
556 } else
557 goto st21;
558 goto st0;
559 tr5:
560 #line 62 "http11_parser.rl"
561 {MARK(mark, p); }
562 goto st24;
563 st24:
564 if ( ++p == pe )
565 goto _test_eof24;
566 case 24:
567 #line 568 "http11_parser.h"
568 switch( (*p) ) {
569 case 32: goto tr37;
570 case 35: goto tr38;
571 case 37: goto st25;
572 case 59: goto tr40;
573 case 63: goto tr41;
574 case 127: goto st0;
576 if ( 0 <= (*p) && (*p) <= 31 )
577 goto st0;
578 goto st24;
579 st25:
580 if ( ++p == pe )
581 goto _test_eof25;
582 case 25:
583 if ( (*p) < 65 ) {
584 if ( 48 <= (*p) && (*p) <= 57 )
585 goto st26;
586 } else if ( (*p) > 70 ) {
587 if ( 97 <= (*p) && (*p) <= 102 )
588 goto st26;
589 } else
590 goto st26;
591 goto st0;
592 st26:
593 if ( ++p == pe )
594 goto _test_eof26;
595 case 26:
596 if ( (*p) < 65 ) {
597 if ( 48 <= (*p) && (*p) <= 57 )
598 goto st24;
599 } else if ( (*p) > 70 ) {
600 if ( 97 <= (*p) && (*p) <= 102 )
601 goto st24;
602 } else
603 goto st24;
604 goto st0;
605 tr40:
606 #line 94 "http11_parser.rl"
608 request_path(parser->data, PTR_TO(mark), LEN(mark,p));
610 goto st27;
611 st27:
612 if ( ++p == pe )
613 goto _test_eof27;
614 case 27:
615 #line 616 "http11_parser.h"
616 switch( (*p) ) {
617 case 32: goto tr7;
618 case 35: goto tr8;
619 case 37: goto st28;
620 case 63: goto st30;
621 case 127: goto st0;
623 if ( 0 <= (*p) && (*p) <= 31 )
624 goto st0;
625 goto st27;
626 st28:
627 if ( ++p == pe )
628 goto _test_eof28;
629 case 28:
630 if ( (*p) < 65 ) {
631 if ( 48 <= (*p) && (*p) <= 57 )
632 goto st29;
633 } else if ( (*p) > 70 ) {
634 if ( 97 <= (*p) && (*p) <= 102 )
635 goto st29;
636 } else
637 goto st29;
638 goto st0;
639 st29:
640 if ( ++p == pe )
641 goto _test_eof29;
642 case 29:
643 if ( (*p) < 65 ) {
644 if ( 48 <= (*p) && (*p) <= 57 )
645 goto st27;
646 } else if ( (*p) > 70 ) {
647 if ( 97 <= (*p) && (*p) <= 102 )
648 goto st27;
649 } else
650 goto st27;
651 goto st0;
652 tr41:
653 #line 94 "http11_parser.rl"
655 request_path(parser->data, PTR_TO(mark), LEN(mark,p));
657 goto st30;
658 st30:
659 if ( ++p == pe )
660 goto _test_eof30;
661 case 30:
662 #line 663 "http11_parser.h"
663 switch( (*p) ) {
664 case 32: goto tr48;
665 case 35: goto tr49;
666 case 37: goto tr50;
667 case 127: goto st0;
669 if ( 0 <= (*p) && (*p) <= 31 )
670 goto st0;
671 goto tr47;
672 tr47:
673 #line 85 "http11_parser.rl"
674 {MARK(query_start, p); }
675 goto st31;
676 st31:
677 if ( ++p == pe )
678 goto _test_eof31;
679 case 31:
680 #line 681 "http11_parser.h"
681 switch( (*p) ) {
682 case 32: goto tr52;
683 case 35: goto tr53;
684 case 37: goto st32;
685 case 127: goto st0;
687 if ( 0 <= (*p) && (*p) <= 31 )
688 goto st0;
689 goto st31;
690 tr50:
691 #line 85 "http11_parser.rl"
692 {MARK(query_start, p); }
693 goto st32;
694 st32:
695 if ( ++p == pe )
696 goto _test_eof32;
697 case 32:
698 #line 699 "http11_parser.h"
699 if ( (*p) < 65 ) {
700 if ( 48 <= (*p) && (*p) <= 57 )
701 goto st33;
702 } else if ( (*p) > 70 ) {
703 if ( 97 <= (*p) && (*p) <= 102 )
704 goto st33;
705 } else
706 goto st33;
707 goto st0;
708 st33:
709 if ( ++p == pe )
710 goto _test_eof33;
711 case 33:
712 if ( (*p) < 65 ) {
713 if ( 48 <= (*p) && (*p) <= 57 )
714 goto st31;
715 } else if ( (*p) > 70 ) {
716 if ( 97 <= (*p) && (*p) <= 102 )
717 goto st31;
718 } else
719 goto st31;
720 goto st0;
721 tr6:
722 #line 66 "http11_parser.rl"
723 { downcase_char((char *)p); }
724 goto st34;
725 st34:
726 if ( ++p == pe )
727 goto _test_eof34;
728 case 34:
729 #line 730 "http11_parser.h"
730 switch( (*p) ) {
731 case 84: goto tr56;
732 case 116: goto tr56;
734 goto st0;
735 tr56:
736 #line 66 "http11_parser.rl"
737 { downcase_char((char *)p); }
738 goto st35;
739 st35:
740 if ( ++p == pe )
741 goto _test_eof35;
742 case 35:
743 #line 744 "http11_parser.h"
744 switch( (*p) ) {
745 case 84: goto tr57;
746 case 116: goto tr57;
748 goto st0;
749 tr57:
750 #line 66 "http11_parser.rl"
751 { downcase_char((char *)p); }
752 goto st36;
753 st36:
754 if ( ++p == pe )
755 goto _test_eof36;
756 case 36:
757 #line 758 "http11_parser.h"
758 switch( (*p) ) {
759 case 80: goto tr58;
760 case 112: goto tr58;
762 goto st0;
763 tr58:
764 #line 66 "http11_parser.rl"
765 { downcase_char((char *)p); }
766 goto st37;
767 st37:
768 if ( ++p == pe )
769 goto _test_eof37;
770 case 37:
771 #line 772 "http11_parser.h"
772 switch( (*p) ) {
773 case 58: goto st38;
774 case 83: goto tr60;
775 case 115: goto tr60;
777 goto st0;
778 st38:
779 if ( ++p == pe )
780 goto _test_eof38;
781 case 38:
782 if ( (*p) == 47 )
783 goto st39;
784 goto st0;
785 st39:
786 if ( ++p == pe )
787 goto _test_eof39;
788 case 39:
789 if ( (*p) == 47 )
790 goto st40;
791 goto st0;
792 st40:
793 if ( ++p == pe )
794 goto _test_eof40;
795 case 40:
796 if ( (*p) < 48 ) {
797 if ( 45 <= (*p) && (*p) <= 46 )
798 goto st41;
799 } else if ( (*p) > 57 ) {
800 if ( (*p) > 90 ) {
801 if ( 97 <= (*p) && (*p) <= 122 )
802 goto st41;
803 } else if ( (*p) >= 65 )
804 goto st41;
805 } else
806 goto st41;
807 goto st0;
808 st41:
809 if ( ++p == pe )
810 goto _test_eof41;
811 case 41:
812 switch( (*p) ) {
813 case 47: goto tr5;
814 case 58: goto st42;
816 if ( (*p) < 65 ) {
817 if ( 45 <= (*p) && (*p) <= 57 )
818 goto st41;
819 } else if ( (*p) > 90 ) {
820 if ( 97 <= (*p) && (*p) <= 122 )
821 goto st41;
822 } else
823 goto st41;
824 goto st0;
825 st42:
826 if ( ++p == pe )
827 goto _test_eof42;
828 case 42:
829 if ( (*p) == 47 )
830 goto tr5;
831 if ( 48 <= (*p) && (*p) <= 57 )
832 goto st42;
833 goto st0;
834 tr60:
835 #line 66 "http11_parser.rl"
836 { downcase_char((char *)p); }
837 goto st43;
838 st43:
839 if ( ++p == pe )
840 goto _test_eof43;
841 case 43:
842 #line 843 "http11_parser.h"
843 if ( (*p) == 58 )
844 goto st38;
845 goto st0;
846 st44:
847 if ( ++p == pe )
848 goto _test_eof44;
849 case 44:
850 switch( (*p) ) {
851 case 32: goto tr2;
852 case 36: goto st45;
853 case 95: goto st45;
855 if ( (*p) < 48 ) {
856 if ( 45 <= (*p) && (*p) <= 46 )
857 goto st45;
858 } else if ( (*p) > 57 ) {
859 if ( 65 <= (*p) && (*p) <= 90 )
860 goto st45;
861 } else
862 goto st45;
863 goto st0;
864 st45:
865 if ( ++p == pe )
866 goto _test_eof45;
867 case 45:
868 switch( (*p) ) {
869 case 32: goto tr2;
870 case 36: goto st46;
871 case 95: goto st46;
873 if ( (*p) < 48 ) {
874 if ( 45 <= (*p) && (*p) <= 46 )
875 goto st46;
876 } else if ( (*p) > 57 ) {
877 if ( 65 <= (*p) && (*p) <= 90 )
878 goto st46;
879 } else
880 goto st46;
881 goto st0;
882 st46:
883 if ( ++p == pe )
884 goto _test_eof46;
885 case 46:
886 switch( (*p) ) {
887 case 32: goto tr2;
888 case 36: goto st47;
889 case 95: goto st47;
891 if ( (*p) < 48 ) {
892 if ( 45 <= (*p) && (*p) <= 46 )
893 goto st47;
894 } else if ( (*p) > 57 ) {
895 if ( 65 <= (*p) && (*p) <= 90 )
896 goto st47;
897 } else
898 goto st47;
899 goto st0;
900 st47:
901 if ( ++p == pe )
902 goto _test_eof47;
903 case 47:
904 switch( (*p) ) {
905 case 32: goto tr2;
906 case 36: goto st48;
907 case 95: goto st48;
909 if ( (*p) < 48 ) {
910 if ( 45 <= (*p) && (*p) <= 46 )
911 goto st48;
912 } else if ( (*p) > 57 ) {
913 if ( 65 <= (*p) && (*p) <= 90 )
914 goto st48;
915 } else
916 goto st48;
917 goto st0;
918 st48:
919 if ( ++p == pe )
920 goto _test_eof48;
921 case 48:
922 switch( (*p) ) {
923 case 32: goto tr2;
924 case 36: goto st49;
925 case 95: goto st49;
927 if ( (*p) < 48 ) {
928 if ( 45 <= (*p) && (*p) <= 46 )
929 goto st49;
930 } else if ( (*p) > 57 ) {
931 if ( 65 <= (*p) && (*p) <= 90 )
932 goto st49;
933 } else
934 goto st49;
935 goto st0;
936 st49:
937 if ( ++p == pe )
938 goto _test_eof49;
939 case 49:
940 switch( (*p) ) {
941 case 32: goto tr2;
942 case 36: goto st50;
943 case 95: goto st50;
945 if ( (*p) < 48 ) {
946 if ( 45 <= (*p) && (*p) <= 46 )
947 goto st50;
948 } else if ( (*p) > 57 ) {
949 if ( 65 <= (*p) && (*p) <= 90 )
950 goto st50;
951 } else
952 goto st50;
953 goto st0;
954 st50:
955 if ( ++p == pe )
956 goto _test_eof50;
957 case 50:
958 switch( (*p) ) {
959 case 32: goto tr2;
960 case 36: goto st51;
961 case 95: goto st51;
963 if ( (*p) < 48 ) {
964 if ( 45 <= (*p) && (*p) <= 46 )
965 goto st51;
966 } else if ( (*p) > 57 ) {
967 if ( 65 <= (*p) && (*p) <= 90 )
968 goto st51;
969 } else
970 goto st51;
971 goto st0;
972 st51:
973 if ( ++p == pe )
974 goto _test_eof51;
975 case 51:
976 switch( (*p) ) {
977 case 32: goto tr2;
978 case 36: goto st52;
979 case 95: goto st52;
981 if ( (*p) < 48 ) {
982 if ( 45 <= (*p) && (*p) <= 46 )
983 goto st52;
984 } else if ( (*p) > 57 ) {
985 if ( 65 <= (*p) && (*p) <= 90 )
986 goto st52;
987 } else
988 goto st52;
989 goto st0;
990 st52:
991 if ( ++p == pe )
992 goto _test_eof52;
993 case 52:
994 switch( (*p) ) {
995 case 32: goto tr2;
996 case 36: goto st53;
997 case 95: goto st53;
999 if ( (*p) < 48 ) {
1000 if ( 45 <= (*p) && (*p) <= 46 )
1001 goto st53;
1002 } else if ( (*p) > 57 ) {
1003 if ( 65 <= (*p) && (*p) <= 90 )
1004 goto st53;
1005 } else
1006 goto st53;
1007 goto st0;
1008 st53:
1009 if ( ++p == pe )
1010 goto _test_eof53;
1011 case 53:
1012 switch( (*p) ) {
1013 case 32: goto tr2;
1014 case 36: goto st54;
1015 case 95: goto st54;
1017 if ( (*p) < 48 ) {
1018 if ( 45 <= (*p) && (*p) <= 46 )
1019 goto st54;
1020 } else if ( (*p) > 57 ) {
1021 if ( 65 <= (*p) && (*p) <= 90 )
1022 goto st54;
1023 } else
1024 goto st54;
1025 goto st0;
1026 st54:
1027 if ( ++p == pe )
1028 goto _test_eof54;
1029 case 54:
1030 switch( (*p) ) {
1031 case 32: goto tr2;
1032 case 36: goto st55;
1033 case 95: goto st55;
1035 if ( (*p) < 48 ) {
1036 if ( 45 <= (*p) && (*p) <= 46 )
1037 goto st55;
1038 } else if ( (*p) > 57 ) {
1039 if ( 65 <= (*p) && (*p) <= 90 )
1040 goto st55;
1041 } else
1042 goto st55;
1043 goto st0;
1044 st55:
1045 if ( ++p == pe )
1046 goto _test_eof55;
1047 case 55:
1048 switch( (*p) ) {
1049 case 32: goto tr2;
1050 case 36: goto st56;
1051 case 95: goto st56;
1053 if ( (*p) < 48 ) {
1054 if ( 45 <= (*p) && (*p) <= 46 )
1055 goto st56;
1056 } else if ( (*p) > 57 ) {
1057 if ( 65 <= (*p) && (*p) <= 90 )
1058 goto st56;
1059 } else
1060 goto st56;
1061 goto st0;
1062 st56:
1063 if ( ++p == pe )
1064 goto _test_eof56;
1065 case 56:
1066 switch( (*p) ) {
1067 case 32: goto tr2;
1068 case 36: goto st57;
1069 case 95: goto st57;
1071 if ( (*p) < 48 ) {
1072 if ( 45 <= (*p) && (*p) <= 46 )
1073 goto st57;
1074 } else if ( (*p) > 57 ) {
1075 if ( 65 <= (*p) && (*p) <= 90 )
1076 goto st57;
1077 } else
1078 goto st57;
1079 goto st0;
1080 st57:
1081 if ( ++p == pe )
1082 goto _test_eof57;
1083 case 57:
1084 switch( (*p) ) {
1085 case 32: goto tr2;
1086 case 36: goto st58;
1087 case 95: goto st58;
1089 if ( (*p) < 48 ) {
1090 if ( 45 <= (*p) && (*p) <= 46 )
1091 goto st58;
1092 } else if ( (*p) > 57 ) {
1093 if ( 65 <= (*p) && (*p) <= 90 )
1094 goto st58;
1095 } else
1096 goto st58;
1097 goto st0;
1098 st58:
1099 if ( ++p == pe )
1100 goto _test_eof58;
1101 case 58:
1102 switch( (*p) ) {
1103 case 32: goto tr2;
1104 case 36: goto st59;
1105 case 95: goto st59;
1107 if ( (*p) < 48 ) {
1108 if ( 45 <= (*p) && (*p) <= 46 )
1109 goto st59;
1110 } else if ( (*p) > 57 ) {
1111 if ( 65 <= (*p) && (*p) <= 90 )
1112 goto st59;
1113 } else
1114 goto st59;
1115 goto st0;
1116 st59:
1117 if ( ++p == pe )
1118 goto _test_eof59;
1119 case 59:
1120 switch( (*p) ) {
1121 case 32: goto tr2;
1122 case 36: goto st60;
1123 case 95: goto st60;
1125 if ( (*p) < 48 ) {
1126 if ( 45 <= (*p) && (*p) <= 46 )
1127 goto st60;
1128 } else if ( (*p) > 57 ) {
1129 if ( 65 <= (*p) && (*p) <= 90 )
1130 goto st60;
1131 } else
1132 goto st60;
1133 goto st0;
1134 st60:
1135 if ( ++p == pe )
1136 goto _test_eof60;
1137 case 60:
1138 switch( (*p) ) {
1139 case 32: goto tr2;
1140 case 36: goto st61;
1141 case 95: goto st61;
1143 if ( (*p) < 48 ) {
1144 if ( 45 <= (*p) && (*p) <= 46 )
1145 goto st61;
1146 } else if ( (*p) > 57 ) {
1147 if ( 65 <= (*p) && (*p) <= 90 )
1148 goto st61;
1149 } else
1150 goto st61;
1151 goto st0;
1152 st61:
1153 if ( ++p == pe )
1154 goto _test_eof61;
1155 case 61:
1156 switch( (*p) ) {
1157 case 32: goto tr2;
1158 case 36: goto st62;
1159 case 95: goto st62;
1161 if ( (*p) < 48 ) {
1162 if ( 45 <= (*p) && (*p) <= 46 )
1163 goto st62;
1164 } else if ( (*p) > 57 ) {
1165 if ( 65 <= (*p) && (*p) <= 90 )
1166 goto st62;
1167 } else
1168 goto st62;
1169 goto st0;
1170 st62:
1171 if ( ++p == pe )
1172 goto _test_eof62;
1173 case 62:
1174 if ( (*p) == 32 )
1175 goto tr2;
1176 goto st0;
1178 _test_eof2: cs = 2; goto _test_eof;
1179 _test_eof3: cs = 3; goto _test_eof;
1180 _test_eof4: cs = 4; goto _test_eof;
1181 _test_eof5: cs = 5; goto _test_eof;
1182 _test_eof6: cs = 6; goto _test_eof;
1183 _test_eof7: cs = 7; goto _test_eof;
1184 _test_eof8: cs = 8; goto _test_eof;
1185 _test_eof9: cs = 9; goto _test_eof;
1186 _test_eof10: cs = 10; goto _test_eof;
1187 _test_eof11: cs = 11; goto _test_eof;
1188 _test_eof12: cs = 12; goto _test_eof;
1189 _test_eof13: cs = 13; goto _test_eof;
1190 _test_eof14: cs = 14; goto _test_eof;
1191 _test_eof15: cs = 15; goto _test_eof;
1192 _test_eof16: cs = 16; goto _test_eof;
1193 _test_eof63: cs = 63; goto _test_eof;
1194 _test_eof17: cs = 17; goto _test_eof;
1195 _test_eof18: cs = 18; goto _test_eof;
1196 _test_eof19: cs = 19; goto _test_eof;
1197 _test_eof20: cs = 20; goto _test_eof;
1198 _test_eof21: cs = 21; goto _test_eof;
1199 _test_eof22: cs = 22; goto _test_eof;
1200 _test_eof23: cs = 23; goto _test_eof;
1201 _test_eof24: cs = 24; goto _test_eof;
1202 _test_eof25: cs = 25; goto _test_eof;
1203 _test_eof26: cs = 26; goto _test_eof;
1204 _test_eof27: cs = 27; goto _test_eof;
1205 _test_eof28: cs = 28; goto _test_eof;
1206 _test_eof29: cs = 29; goto _test_eof;
1207 _test_eof30: cs = 30; goto _test_eof;
1208 _test_eof31: cs = 31; goto _test_eof;
1209 _test_eof32: cs = 32; goto _test_eof;
1210 _test_eof33: cs = 33; goto _test_eof;
1211 _test_eof34: cs = 34; goto _test_eof;
1212 _test_eof35: cs = 35; goto _test_eof;
1213 _test_eof36: cs = 36; goto _test_eof;
1214 _test_eof37: cs = 37; goto _test_eof;
1215 _test_eof38: cs = 38; goto _test_eof;
1216 _test_eof39: cs = 39; goto _test_eof;
1217 _test_eof40: cs = 40; goto _test_eof;
1218 _test_eof41: cs = 41; goto _test_eof;
1219 _test_eof42: cs = 42; goto _test_eof;
1220 _test_eof43: cs = 43; goto _test_eof;
1221 _test_eof44: cs = 44; goto _test_eof;
1222 _test_eof45: cs = 45; goto _test_eof;
1223 _test_eof46: cs = 46; goto _test_eof;
1224 _test_eof47: cs = 47; goto _test_eof;
1225 _test_eof48: cs = 48; goto _test_eof;
1226 _test_eof49: cs = 49; goto _test_eof;
1227 _test_eof50: cs = 50; goto _test_eof;
1228 _test_eof51: cs = 51; goto _test_eof;
1229 _test_eof52: cs = 52; goto _test_eof;
1230 _test_eof53: cs = 53; goto _test_eof;
1231 _test_eof54: cs = 54; goto _test_eof;
1232 _test_eof55: cs = 55; goto _test_eof;
1233 _test_eof56: cs = 56; goto _test_eof;
1234 _test_eof57: cs = 57; goto _test_eof;
1235 _test_eof58: cs = 58; goto _test_eof;
1236 _test_eof59: cs = 59; goto _test_eof;
1237 _test_eof60: cs = 60; goto _test_eof;
1238 _test_eof61: cs = 61; goto _test_eof;
1239 _test_eof62: cs = 62; goto _test_eof;
1241 _test_eof: {}
1242 _out: {}
1245 #line 134 "http11_parser.rl"
1247 if (!http_parser_has_error(parser))
1248 parser->cs = cs;
1249 parser->nread += p - (buffer + off);
1251 assert(p <= pe && "buffer overflow after parsing execute");
1252 assert(parser->nread <= len && "nread longer than length");
1253 assert(parser->body_start <= len && "body starts after buffer end");
1254 assert(parser->mark < len && "mark is after buffer end");
1255 assert(parser->field_len <= len && "field has length longer than whole buffer");
1256 assert(parser->field_start < len && "field starts after buffer end");
1259 static int http_parser_has_error(http_parser *parser) {
1260 return parser->cs == http_parser_error;
1263 static int http_parser_is_finished(http_parser *parser) {
1264 return parser->cs == http_parser_first_final;
1266 #endif /* http11_parser_h */