engineyard-mongrel 1.1.4

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