unicorn 0.1.0

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