piesync-puma 3.12.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/History.md +1429 -0
  3. data/LICENSE +26 -0
  4. data/README.md +280 -0
  5. data/bin/puma +10 -0
  6. data/bin/puma-wild +31 -0
  7. data/bin/pumactl +12 -0
  8. data/docs/architecture.md +36 -0
  9. data/docs/deployment.md +91 -0
  10. data/docs/images/puma-connection-flow-no-reactor.png +0 -0
  11. data/docs/images/puma-connection-flow.png +0 -0
  12. data/docs/images/puma-general-arch.png +0 -0
  13. data/docs/nginx.md +80 -0
  14. data/docs/plugins.md +28 -0
  15. data/docs/restart.md +39 -0
  16. data/docs/signals.md +96 -0
  17. data/docs/systemd.md +272 -0
  18. data/ext/puma_http11/PumaHttp11Service.java +17 -0
  19. data/ext/puma_http11/ext_help.h +15 -0
  20. data/ext/puma_http11/extconf.rb +15 -0
  21. data/ext/puma_http11/http11_parser.c +1071 -0
  22. data/ext/puma_http11/http11_parser.h +65 -0
  23. data/ext/puma_http11/http11_parser.java.rl +161 -0
  24. data/ext/puma_http11/http11_parser.rl +149 -0
  25. data/ext/puma_http11/http11_parser_common.rl +54 -0
  26. data/ext/puma_http11/io_buffer.c +155 -0
  27. data/ext/puma_http11/mini_ssl.c +494 -0
  28. data/ext/puma_http11/org/jruby/puma/Http11.java +234 -0
  29. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +470 -0
  30. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +352 -0
  31. data/ext/puma_http11/puma_http11.c +500 -0
  32. data/lib/puma.rb +23 -0
  33. data/lib/puma/accept_nonblock.rb +23 -0
  34. data/lib/puma/app/status.rb +74 -0
  35. data/lib/puma/binder.rb +413 -0
  36. data/lib/puma/cli.rb +235 -0
  37. data/lib/puma/client.rb +480 -0
  38. data/lib/puma/cluster.rb +531 -0
  39. data/lib/puma/commonlogger.rb +108 -0
  40. data/lib/puma/compat.rb +14 -0
  41. data/lib/puma/configuration.rb +361 -0
  42. data/lib/puma/const.rb +239 -0
  43. data/lib/puma/control_cli.rb +264 -0
  44. data/lib/puma/convenient.rb +25 -0
  45. data/lib/puma/daemon_ext.rb +33 -0
  46. data/lib/puma/delegation.rb +13 -0
  47. data/lib/puma/detect.rb +15 -0
  48. data/lib/puma/dsl.rb +518 -0
  49. data/lib/puma/events.rb +153 -0
  50. data/lib/puma/io_buffer.rb +9 -0
  51. data/lib/puma/java_io_buffer.rb +47 -0
  52. data/lib/puma/jruby_restart.rb +84 -0
  53. data/lib/puma/launcher.rb +433 -0
  54. data/lib/puma/minissl.rb +285 -0
  55. data/lib/puma/null_io.rb +44 -0
  56. data/lib/puma/plugin.rb +117 -0
  57. data/lib/puma/plugin/tmp_restart.rb +34 -0
  58. data/lib/puma/rack/backports/uri/common_193.rb +33 -0
  59. data/lib/puma/rack/builder.rb +299 -0
  60. data/lib/puma/rack/urlmap.rb +91 -0
  61. data/lib/puma/rack_default.rb +7 -0
  62. data/lib/puma/reactor.rb +347 -0
  63. data/lib/puma/runner.rb +184 -0
  64. data/lib/puma/server.rb +1072 -0
  65. data/lib/puma/single.rb +123 -0
  66. data/lib/puma/state_file.rb +31 -0
  67. data/lib/puma/tcp_logger.rb +41 -0
  68. data/lib/puma/thread_pool.rb +346 -0
  69. data/lib/puma/util.rb +129 -0
  70. data/lib/rack/handler/puma.rb +115 -0
  71. data/tools/jungle/README.md +19 -0
  72. data/tools/jungle/init.d/README.md +61 -0
  73. data/tools/jungle/init.d/puma +421 -0
  74. data/tools/jungle/init.d/run-puma +18 -0
  75. data/tools/jungle/rc.d/README.md +74 -0
  76. data/tools/jungle/rc.d/puma +61 -0
  77. data/tools/jungle/rc.d/puma.conf +10 -0
  78. data/tools/jungle/upstart/README.md +61 -0
  79. data/tools/jungle/upstart/puma-manager.conf +31 -0
  80. data/tools/jungle/upstart/puma.conf +69 -0
  81. data/tools/trickletest.rb +45 -0
  82. metadata +131 -0
@@ -0,0 +1,17 @@
1
+ package puma;
2
+
3
+ import java.io.IOException;
4
+
5
+ import org.jruby.Ruby;
6
+ import org.jruby.runtime.load.BasicLibraryService;
7
+
8
+ import org.jruby.puma.Http11;
9
+ import org.jruby.puma.MiniSSL;
10
+
11
+ public class PumaHttp11Service implements BasicLibraryService {
12
+ public boolean basicLoad(final Ruby runtime) throws IOException {
13
+ Http11.createHttp11(runtime);
14
+ MiniSSL.createMiniSSL(runtime);
15
+ return true;
16
+ }
17
+ }
@@ -0,0 +1,15 @@
1
+ #ifndef ext_help_h
2
+ #define ext_help_h
3
+
4
+ #define RAISE_NOT_NULL(T) if(T == NULL) rb_raise(rb_eArgError, "%s", "NULL found for " # T " when shouldn't be.");
5
+ #define DATA_GET(from,type,name) Data_Get_Struct(from,type,name); RAISE_NOT_NULL(name);
6
+ #define REQUIRE_TYPE(V, T) if(TYPE(V) != T) rb_raise(rb_eTypeError, "%s", "Wrong argument type for " # V " required " # T);
7
+ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
8
+
9
+ #ifdef DEBUG
10
+ #define TRACE() fprintf(stderr, "> %s:%d:%s\n", __FILE__, __LINE__, __FUNCTION__)
11
+ #else
12
+ #define TRACE()
13
+ #endif
14
+
15
+ #endif
@@ -0,0 +1,15 @@
1
+ require 'mkmf'
2
+
3
+ dir_config("puma_http11")
4
+
5
+ unless ENV["DISABLE_SSL"]
6
+ dir_config("openssl")
7
+
8
+ if %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} and
9
+ %w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
10
+
11
+ have_header "openssl/bio.h"
12
+ end
13
+ end
14
+
15
+ create_makefile("puma/puma_http11")
@@ -0,0 +1,1071 @@
1
+
2
+ #line 1 "ext/puma_http11/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
+ * License 3-clause BSD
7
+ */
8
+ #include "http11_parser.h"
9
+ #include <stdio.h>
10
+ #include <assert.h>
11
+ #include <stdlib.h>
12
+ #include <ctype.h>
13
+ #include <string.h>
14
+
15
+ /*
16
+ * capitalizes all lower-case ASCII characters,
17
+ * converts dashes to underscores, and underscores to commas.
18
+ */
19
+ static void snake_upcase_char(char *c)
20
+ {
21
+ if (*c >= 'a' && *c <= 'z')
22
+ *c &= ~0x20;
23
+ else if (*c == '_')
24
+ *c = ',';
25
+ else if (*c == '-')
26
+ *c = '_';
27
+ }
28
+
29
+ #define LEN(AT, FPC) (FPC - buffer - parser->AT)
30
+ #define MARK(M,FPC) (parser->M = (FPC) - buffer)
31
+ #define PTR_TO(F) (buffer + parser->F)
32
+
33
+ /** Machine **/
34
+
35
+
36
+ #line 79 "ext/puma_http11/http11_parser.rl"
37
+
38
+
39
+ /** Data **/
40
+
41
+ #line 40 "ext/puma_http11/http11_parser.c"
42
+ static const int puma_parser_start = 1;
43
+ static const int puma_parser_first_final = 47;
44
+ static const int puma_parser_error = 0;
45
+
46
+ static const int puma_parser_en_main = 1;
47
+
48
+
49
+ #line 83 "ext/puma_http11/http11_parser.rl"
50
+
51
+ int puma_parser_init(puma_parser *parser) {
52
+ int cs = 0;
53
+
54
+ #line 53 "ext/puma_http11/http11_parser.c"
55
+ {
56
+ cs = puma_parser_start;
57
+ }
58
+
59
+ #line 87 "ext/puma_http11/http11_parser.rl"
60
+ parser->cs = cs;
61
+ parser->body_start = 0;
62
+ parser->content_len = 0;
63
+ parser->mark = 0;
64
+ parser->nread = 0;
65
+ parser->field_len = 0;
66
+ parser->field_start = 0;
67
+ parser->request = Qnil;
68
+ parser->body = Qnil;
69
+
70
+ return 1;
71
+ }
72
+
73
+
74
+ /** exec **/
75
+ size_t puma_parser_execute(puma_parser *parser, const char *buffer, size_t len, size_t off) {
76
+ const char *p, *pe;
77
+ int cs = parser->cs;
78
+
79
+ assert(off <= len && "offset past end of buffer");
80
+
81
+ p = buffer+off;
82
+ pe = buffer+len;
83
+
84
+ /* assert(*pe == '\0' && "pointer does not end on NUL"); */
85
+ assert((size_t) (pe - p) == len - off && "pointers aren't same distance");
86
+
87
+
88
+ #line 87 "ext/puma_http11/http11_parser.c"
89
+ {
90
+ if ( p == pe )
91
+ goto _test_eof;
92
+ switch ( cs )
93
+ {
94
+ case 1:
95
+ switch( (*p) ) {
96
+ case 36: goto tr0;
97
+ case 95: goto tr0;
98
+ }
99
+ if ( (*p) < 48 ) {
100
+ if ( 45 <= (*p) && (*p) <= 46 )
101
+ goto tr0;
102
+ } else if ( (*p) > 57 ) {
103
+ if ( 65 <= (*p) && (*p) <= 90 )
104
+ goto tr0;
105
+ } else
106
+ goto tr0;
107
+ goto st0;
108
+ st0:
109
+ cs = 0;
110
+ goto _out;
111
+ tr0:
112
+ #line 35 "ext/puma_http11/http11_parser.rl"
113
+ { MARK(mark, p); }
114
+ goto st2;
115
+ st2:
116
+ if ( ++p == pe )
117
+ goto _test_eof2;
118
+ case 2:
119
+ #line 118 "ext/puma_http11/http11_parser.c"
120
+ switch( (*p) ) {
121
+ case 32: goto tr2;
122
+ case 36: goto st28;
123
+ case 95: goto st28;
124
+ }
125
+ if ( (*p) < 48 ) {
126
+ if ( 45 <= (*p) && (*p) <= 46 )
127
+ goto st28;
128
+ } else if ( (*p) > 57 ) {
129
+ if ( 65 <= (*p) && (*p) <= 90 )
130
+ goto st28;
131
+ } else
132
+ goto st28;
133
+ goto st0;
134
+ tr2:
135
+ #line 48 "ext/puma_http11/http11_parser.rl"
136
+ {
137
+ parser->request_method(parser, PTR_TO(mark), LEN(mark, p));
138
+ }
139
+ goto st3;
140
+ st3:
141
+ if ( ++p == pe )
142
+ goto _test_eof3;
143
+ case 3:
144
+ #line 143 "ext/puma_http11/http11_parser.c"
145
+ switch( (*p) ) {
146
+ case 42: goto tr4;
147
+ case 43: goto tr5;
148
+ case 47: goto tr6;
149
+ case 58: goto tr7;
150
+ }
151
+ if ( (*p) < 65 ) {
152
+ if ( 45 <= (*p) && (*p) <= 57 )
153
+ goto tr5;
154
+ } else if ( (*p) > 90 ) {
155
+ if ( 97 <= (*p) && (*p) <= 122 )
156
+ goto tr5;
157
+ } else
158
+ goto tr5;
159
+ goto st0;
160
+ tr4:
161
+ #line 35 "ext/puma_http11/http11_parser.rl"
162
+ { MARK(mark, p); }
163
+ goto st4;
164
+ st4:
165
+ if ( ++p == pe )
166
+ goto _test_eof4;
167
+ case 4:
168
+ #line 167 "ext/puma_http11/http11_parser.c"
169
+ switch( (*p) ) {
170
+ case 32: goto tr8;
171
+ case 35: goto tr9;
172
+ }
173
+ goto st0;
174
+ tr8:
175
+ #line 51 "ext/puma_http11/http11_parser.rl"
176
+ {
177
+ parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
178
+ }
179
+ goto st5;
180
+ tr31:
181
+ #line 35 "ext/puma_http11/http11_parser.rl"
182
+ { MARK(mark, p); }
183
+ #line 54 "ext/puma_http11/http11_parser.rl"
184
+ {
185
+ parser->fragment(parser, PTR_TO(mark), LEN(mark, p));
186
+ }
187
+ goto st5;
188
+ tr33:
189
+ #line 54 "ext/puma_http11/http11_parser.rl"
190
+ {
191
+ parser->fragment(parser, PTR_TO(mark), LEN(mark, p));
192
+ }
193
+ goto st5;
194
+ tr37:
195
+ #line 67 "ext/puma_http11/http11_parser.rl"
196
+ {
197
+ parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
198
+ }
199
+ #line 51 "ext/puma_http11/http11_parser.rl"
200
+ {
201
+ parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
202
+ }
203
+ goto st5;
204
+ tr44:
205
+ #line 58 "ext/puma_http11/http11_parser.rl"
206
+ { MARK(query_start, p); }
207
+ #line 59 "ext/puma_http11/http11_parser.rl"
208
+ {
209
+ parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
210
+ }
211
+ #line 51 "ext/puma_http11/http11_parser.rl"
212
+ {
213
+ parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
214
+ }
215
+ goto st5;
216
+ tr47:
217
+ #line 59 "ext/puma_http11/http11_parser.rl"
218
+ {
219
+ parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
220
+ }
221
+ #line 51 "ext/puma_http11/http11_parser.rl"
222
+ {
223
+ parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
224
+ }
225
+ goto st5;
226
+ st5:
227
+ if ( ++p == pe )
228
+ goto _test_eof5;
229
+ case 5:
230
+ #line 229 "ext/puma_http11/http11_parser.c"
231
+ if ( (*p) == 72 )
232
+ goto tr10;
233
+ goto st0;
234
+ tr10:
235
+ #line 35 "ext/puma_http11/http11_parser.rl"
236
+ { MARK(mark, p); }
237
+ goto st6;
238
+ st6:
239
+ if ( ++p == pe )
240
+ goto _test_eof6;
241
+ case 6:
242
+ #line 241 "ext/puma_http11/http11_parser.c"
243
+ if ( (*p) == 84 )
244
+ goto st7;
245
+ goto st0;
246
+ st7:
247
+ if ( ++p == pe )
248
+ goto _test_eof7;
249
+ case 7:
250
+ if ( (*p) == 84 )
251
+ goto st8;
252
+ goto st0;
253
+ st8:
254
+ if ( ++p == pe )
255
+ goto _test_eof8;
256
+ case 8:
257
+ if ( (*p) == 80 )
258
+ goto st9;
259
+ goto st0;
260
+ st9:
261
+ if ( ++p == pe )
262
+ goto _test_eof9;
263
+ case 9:
264
+ if ( (*p) == 47 )
265
+ goto st10;
266
+ goto st0;
267
+ st10:
268
+ if ( ++p == pe )
269
+ goto _test_eof10;
270
+ case 10:
271
+ if ( 48 <= (*p) && (*p) <= 57 )
272
+ goto st11;
273
+ goto st0;
274
+ st11:
275
+ if ( ++p == pe )
276
+ goto _test_eof11;
277
+ case 11:
278
+ if ( (*p) == 46 )
279
+ goto st12;
280
+ if ( 48 <= (*p) && (*p) <= 57 )
281
+ goto st11;
282
+ goto st0;
283
+ st12:
284
+ if ( ++p == pe )
285
+ goto _test_eof12;
286
+ case 12:
287
+ if ( 48 <= (*p) && (*p) <= 57 )
288
+ goto st13;
289
+ goto st0;
290
+ st13:
291
+ if ( ++p == pe )
292
+ goto _test_eof13;
293
+ case 13:
294
+ if ( (*p) == 13 )
295
+ goto tr18;
296
+ if ( 48 <= (*p) && (*p) <= 57 )
297
+ goto st13;
298
+ goto st0;
299
+ tr18:
300
+ #line 63 "ext/puma_http11/http11_parser.rl"
301
+ {
302
+ parser->http_version(parser, PTR_TO(mark), LEN(mark, p));
303
+ }
304
+ goto st14;
305
+ tr26:
306
+ #line 44 "ext/puma_http11/http11_parser.rl"
307
+ { MARK(mark, p); }
308
+ #line 45 "ext/puma_http11/http11_parser.rl"
309
+ {
310
+ parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
311
+ }
312
+ goto st14;
313
+ tr29:
314
+ #line 45 "ext/puma_http11/http11_parser.rl"
315
+ {
316
+ parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
317
+ }
318
+ goto st14;
319
+ st14:
320
+ if ( ++p == pe )
321
+ goto _test_eof14;
322
+ case 14:
323
+ #line 322 "ext/puma_http11/http11_parser.c"
324
+ if ( (*p) == 10 )
325
+ goto st15;
326
+ goto st0;
327
+ st15:
328
+ if ( ++p == pe )
329
+ goto _test_eof15;
330
+ case 15:
331
+ switch( (*p) ) {
332
+ case 13: goto st16;
333
+ case 33: goto tr21;
334
+ case 124: goto tr21;
335
+ case 126: goto tr21;
336
+ }
337
+ if ( (*p) < 45 ) {
338
+ if ( (*p) > 39 ) {
339
+ if ( 42 <= (*p) && (*p) <= 43 )
340
+ goto tr21;
341
+ } else if ( (*p) >= 35 )
342
+ goto tr21;
343
+ } else if ( (*p) > 46 ) {
344
+ if ( (*p) < 65 ) {
345
+ if ( 48 <= (*p) && (*p) <= 57 )
346
+ goto tr21;
347
+ } else if ( (*p) > 90 ) {
348
+ if ( 94 <= (*p) && (*p) <= 122 )
349
+ goto tr21;
350
+ } else
351
+ goto tr21;
352
+ } else
353
+ goto tr21;
354
+ goto st0;
355
+ st16:
356
+ if ( ++p == pe )
357
+ goto _test_eof16;
358
+ case 16:
359
+ if ( (*p) == 10 )
360
+ goto tr22;
361
+ goto st0;
362
+ tr22:
363
+ #line 71 "ext/puma_http11/http11_parser.rl"
364
+ {
365
+ parser->body_start = p - buffer + 1;
366
+ parser->header_done(parser, p + 1, pe - p - 1);
367
+ {p++; cs = 47; goto _out;}
368
+ }
369
+ goto st47;
370
+ st47:
371
+ if ( ++p == pe )
372
+ goto _test_eof47;
373
+ case 47:
374
+ #line 373 "ext/puma_http11/http11_parser.c"
375
+ goto st0;
376
+ tr21:
377
+ #line 38 "ext/puma_http11/http11_parser.rl"
378
+ { MARK(field_start, p); }
379
+ #line 39 "ext/puma_http11/http11_parser.rl"
380
+ { snake_upcase_char((char *)p); }
381
+ goto st17;
382
+ tr23:
383
+ #line 39 "ext/puma_http11/http11_parser.rl"
384
+ { snake_upcase_char((char *)p); }
385
+ goto st17;
386
+ st17:
387
+ if ( ++p == pe )
388
+ goto _test_eof17;
389
+ case 17:
390
+ #line 389 "ext/puma_http11/http11_parser.c"
391
+ switch( (*p) ) {
392
+ case 33: goto tr23;
393
+ case 58: goto tr24;
394
+ case 124: goto tr23;
395
+ case 126: goto tr23;
396
+ }
397
+ if ( (*p) < 45 ) {
398
+ if ( (*p) > 39 ) {
399
+ if ( 42 <= (*p) && (*p) <= 43 )
400
+ goto tr23;
401
+ } else if ( (*p) >= 35 )
402
+ goto tr23;
403
+ } else if ( (*p) > 46 ) {
404
+ if ( (*p) < 65 ) {
405
+ if ( 48 <= (*p) && (*p) <= 57 )
406
+ goto tr23;
407
+ } else if ( (*p) > 90 ) {
408
+ if ( 94 <= (*p) && (*p) <= 122 )
409
+ goto tr23;
410
+ } else
411
+ goto tr23;
412
+ } else
413
+ goto tr23;
414
+ goto st0;
415
+ tr24:
416
+ #line 40 "ext/puma_http11/http11_parser.rl"
417
+ {
418
+ parser->field_len = LEN(field_start, p);
419
+ }
420
+ goto st18;
421
+ tr27:
422
+ #line 44 "ext/puma_http11/http11_parser.rl"
423
+ { MARK(mark, p); }
424
+ goto st18;
425
+ st18:
426
+ if ( ++p == pe )
427
+ goto _test_eof18;
428
+ case 18:
429
+ #line 428 "ext/puma_http11/http11_parser.c"
430
+ switch( (*p) ) {
431
+ case 13: goto tr26;
432
+ case 32: goto tr27;
433
+ }
434
+ goto tr25;
435
+ tr25:
436
+ #line 44 "ext/puma_http11/http11_parser.rl"
437
+ { MARK(mark, p); }
438
+ goto st19;
439
+ st19:
440
+ if ( ++p == pe )
441
+ goto _test_eof19;
442
+ case 19:
443
+ #line 442 "ext/puma_http11/http11_parser.c"
444
+ if ( (*p) == 13 )
445
+ goto tr29;
446
+ goto st19;
447
+ tr9:
448
+ #line 51 "ext/puma_http11/http11_parser.rl"
449
+ {
450
+ parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
451
+ }
452
+ goto st20;
453
+ tr38:
454
+ #line 67 "ext/puma_http11/http11_parser.rl"
455
+ {
456
+ parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
457
+ }
458
+ #line 51 "ext/puma_http11/http11_parser.rl"
459
+ {
460
+ parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
461
+ }
462
+ goto st20;
463
+ tr45:
464
+ #line 58 "ext/puma_http11/http11_parser.rl"
465
+ { MARK(query_start, p); }
466
+ #line 59 "ext/puma_http11/http11_parser.rl"
467
+ {
468
+ parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
469
+ }
470
+ #line 51 "ext/puma_http11/http11_parser.rl"
471
+ {
472
+ parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
473
+ }
474
+ goto st20;
475
+ tr48:
476
+ #line 59 "ext/puma_http11/http11_parser.rl"
477
+ {
478
+ parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
479
+ }
480
+ #line 51 "ext/puma_http11/http11_parser.rl"
481
+ {
482
+ parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
483
+ }
484
+ goto st20;
485
+ st20:
486
+ if ( ++p == pe )
487
+ goto _test_eof20;
488
+ case 20:
489
+ #line 488 "ext/puma_http11/http11_parser.c"
490
+ switch( (*p) ) {
491
+ case 32: goto tr31;
492
+ case 60: goto st0;
493
+ case 62: goto st0;
494
+ case 127: goto st0;
495
+ }
496
+ if ( (*p) > 31 ) {
497
+ if ( 34 <= (*p) && (*p) <= 35 )
498
+ goto st0;
499
+ } else if ( (*p) >= 0 )
500
+ goto st0;
501
+ goto tr30;
502
+ tr30:
503
+ #line 35 "ext/puma_http11/http11_parser.rl"
504
+ { MARK(mark, p); }
505
+ goto st21;
506
+ st21:
507
+ if ( ++p == pe )
508
+ goto _test_eof21;
509
+ case 21:
510
+ #line 509 "ext/puma_http11/http11_parser.c"
511
+ switch( (*p) ) {
512
+ case 32: goto tr33;
513
+ case 60: goto st0;
514
+ case 62: goto st0;
515
+ case 127: goto st0;
516
+ }
517
+ if ( (*p) > 31 ) {
518
+ if ( 34 <= (*p) && (*p) <= 35 )
519
+ goto st0;
520
+ } else if ( (*p) >= 0 )
521
+ goto st0;
522
+ goto st21;
523
+ tr5:
524
+ #line 35 "ext/puma_http11/http11_parser.rl"
525
+ { MARK(mark, p); }
526
+ goto st22;
527
+ st22:
528
+ if ( ++p == pe )
529
+ goto _test_eof22;
530
+ case 22:
531
+ #line 530 "ext/puma_http11/http11_parser.c"
532
+ switch( (*p) ) {
533
+ case 43: goto st22;
534
+ case 58: goto st23;
535
+ }
536
+ if ( (*p) < 48 ) {
537
+ if ( 45 <= (*p) && (*p) <= 46 )
538
+ goto st22;
539
+ } else if ( (*p) > 57 ) {
540
+ if ( (*p) > 90 ) {
541
+ if ( 97 <= (*p) && (*p) <= 122 )
542
+ goto st22;
543
+ } else if ( (*p) >= 65 )
544
+ goto st22;
545
+ } else
546
+ goto st22;
547
+ goto st0;
548
+ tr7:
549
+ #line 35 "ext/puma_http11/http11_parser.rl"
550
+ { MARK(mark, p); }
551
+ goto st23;
552
+ st23:
553
+ if ( ++p == pe )
554
+ goto _test_eof23;
555
+ case 23:
556
+ #line 555 "ext/puma_http11/http11_parser.c"
557
+ switch( (*p) ) {
558
+ case 32: goto tr8;
559
+ case 34: goto st0;
560
+ case 35: goto tr9;
561
+ case 60: goto st0;
562
+ case 62: goto st0;
563
+ case 127: goto st0;
564
+ }
565
+ if ( 0 <= (*p) && (*p) <= 31 )
566
+ goto st0;
567
+ goto st23;
568
+ tr6:
569
+ #line 35 "ext/puma_http11/http11_parser.rl"
570
+ { MARK(mark, p); }
571
+ goto st24;
572
+ st24:
573
+ if ( ++p == pe )
574
+ goto _test_eof24;
575
+ case 24:
576
+ #line 575 "ext/puma_http11/http11_parser.c"
577
+ switch( (*p) ) {
578
+ case 32: goto tr37;
579
+ case 34: goto st0;
580
+ case 35: goto tr38;
581
+ case 59: goto tr39;
582
+ case 60: goto st0;
583
+ case 62: goto st0;
584
+ case 63: goto tr40;
585
+ case 127: goto st0;
586
+ }
587
+ if ( 0 <= (*p) && (*p) <= 31 )
588
+ goto st0;
589
+ goto st24;
590
+ tr39:
591
+ #line 67 "ext/puma_http11/http11_parser.rl"
592
+ {
593
+ parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
594
+ }
595
+ goto st25;
596
+ st25:
597
+ if ( ++p == pe )
598
+ goto _test_eof25;
599
+ case 25:
600
+ #line 599 "ext/puma_http11/http11_parser.c"
601
+ switch( (*p) ) {
602
+ case 32: goto tr8;
603
+ case 34: goto st0;
604
+ case 35: goto tr9;
605
+ case 60: goto st0;
606
+ case 62: goto st0;
607
+ case 63: goto st26;
608
+ case 127: goto st0;
609
+ }
610
+ if ( 0 <= (*p) && (*p) <= 31 )
611
+ goto st0;
612
+ goto st25;
613
+ tr40:
614
+ #line 67 "ext/puma_http11/http11_parser.rl"
615
+ {
616
+ parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
617
+ }
618
+ goto st26;
619
+ st26:
620
+ if ( ++p == pe )
621
+ goto _test_eof26;
622
+ case 26:
623
+ #line 622 "ext/puma_http11/http11_parser.c"
624
+ switch( (*p) ) {
625
+ case 32: goto tr44;
626
+ case 34: goto st0;
627
+ case 35: goto tr45;
628
+ case 60: goto st0;
629
+ case 62: goto st0;
630
+ case 127: goto st0;
631
+ }
632
+ if ( 0 <= (*p) && (*p) <= 31 )
633
+ goto st0;
634
+ goto tr43;
635
+ tr43:
636
+ #line 58 "ext/puma_http11/http11_parser.rl"
637
+ { MARK(query_start, p); }
638
+ goto st27;
639
+ st27:
640
+ if ( ++p == pe )
641
+ goto _test_eof27;
642
+ case 27:
643
+ #line 642 "ext/puma_http11/http11_parser.c"
644
+ switch( (*p) ) {
645
+ case 32: goto tr47;
646
+ case 34: goto st0;
647
+ case 35: goto tr48;
648
+ case 60: goto st0;
649
+ case 62: goto st0;
650
+ case 127: goto st0;
651
+ }
652
+ if ( 0 <= (*p) && (*p) <= 31 )
653
+ goto st0;
654
+ goto st27;
655
+ st28:
656
+ if ( ++p == pe )
657
+ goto _test_eof28;
658
+ case 28:
659
+ switch( (*p) ) {
660
+ case 32: goto tr2;
661
+ case 36: goto st29;
662
+ case 95: goto st29;
663
+ }
664
+ if ( (*p) < 48 ) {
665
+ if ( 45 <= (*p) && (*p) <= 46 )
666
+ goto st29;
667
+ } else if ( (*p) > 57 ) {
668
+ if ( 65 <= (*p) && (*p) <= 90 )
669
+ goto st29;
670
+ } else
671
+ goto st29;
672
+ goto st0;
673
+ st29:
674
+ if ( ++p == pe )
675
+ goto _test_eof29;
676
+ case 29:
677
+ switch( (*p) ) {
678
+ case 32: goto tr2;
679
+ case 36: goto st30;
680
+ case 95: goto st30;
681
+ }
682
+ if ( (*p) < 48 ) {
683
+ if ( 45 <= (*p) && (*p) <= 46 )
684
+ goto st30;
685
+ } else if ( (*p) > 57 ) {
686
+ if ( 65 <= (*p) && (*p) <= 90 )
687
+ goto st30;
688
+ } else
689
+ goto st30;
690
+ goto st0;
691
+ st30:
692
+ if ( ++p == pe )
693
+ goto _test_eof30;
694
+ case 30:
695
+ switch( (*p) ) {
696
+ case 32: goto tr2;
697
+ case 36: goto st31;
698
+ case 95: goto st31;
699
+ }
700
+ if ( (*p) < 48 ) {
701
+ if ( 45 <= (*p) && (*p) <= 46 )
702
+ goto st31;
703
+ } else if ( (*p) > 57 ) {
704
+ if ( 65 <= (*p) && (*p) <= 90 )
705
+ goto st31;
706
+ } else
707
+ goto st31;
708
+ goto st0;
709
+ st31:
710
+ if ( ++p == pe )
711
+ goto _test_eof31;
712
+ case 31:
713
+ switch( (*p) ) {
714
+ case 32: goto tr2;
715
+ case 36: goto st32;
716
+ case 95: goto st32;
717
+ }
718
+ if ( (*p) < 48 ) {
719
+ if ( 45 <= (*p) && (*p) <= 46 )
720
+ goto st32;
721
+ } else if ( (*p) > 57 ) {
722
+ if ( 65 <= (*p) && (*p) <= 90 )
723
+ goto st32;
724
+ } else
725
+ goto st32;
726
+ goto st0;
727
+ st32:
728
+ if ( ++p == pe )
729
+ goto _test_eof32;
730
+ case 32:
731
+ switch( (*p) ) {
732
+ case 32: goto tr2;
733
+ case 36: goto st33;
734
+ case 95: goto st33;
735
+ }
736
+ if ( (*p) < 48 ) {
737
+ if ( 45 <= (*p) && (*p) <= 46 )
738
+ goto st33;
739
+ } else if ( (*p) > 57 ) {
740
+ if ( 65 <= (*p) && (*p) <= 90 )
741
+ goto st33;
742
+ } else
743
+ goto st33;
744
+ goto st0;
745
+ st33:
746
+ if ( ++p == pe )
747
+ goto _test_eof33;
748
+ case 33:
749
+ switch( (*p) ) {
750
+ case 32: goto tr2;
751
+ case 36: goto st34;
752
+ case 95: goto st34;
753
+ }
754
+ if ( (*p) < 48 ) {
755
+ if ( 45 <= (*p) && (*p) <= 46 )
756
+ goto st34;
757
+ } else if ( (*p) > 57 ) {
758
+ if ( 65 <= (*p) && (*p) <= 90 )
759
+ goto st34;
760
+ } else
761
+ goto st34;
762
+ goto st0;
763
+ st34:
764
+ if ( ++p == pe )
765
+ goto _test_eof34;
766
+ case 34:
767
+ switch( (*p) ) {
768
+ case 32: goto tr2;
769
+ case 36: goto st35;
770
+ case 95: goto st35;
771
+ }
772
+ if ( (*p) < 48 ) {
773
+ if ( 45 <= (*p) && (*p) <= 46 )
774
+ goto st35;
775
+ } else if ( (*p) > 57 ) {
776
+ if ( 65 <= (*p) && (*p) <= 90 )
777
+ goto st35;
778
+ } else
779
+ goto st35;
780
+ goto st0;
781
+ st35:
782
+ if ( ++p == pe )
783
+ goto _test_eof35;
784
+ case 35:
785
+ switch( (*p) ) {
786
+ case 32: goto tr2;
787
+ case 36: goto st36;
788
+ case 95: goto st36;
789
+ }
790
+ if ( (*p) < 48 ) {
791
+ if ( 45 <= (*p) && (*p) <= 46 )
792
+ goto st36;
793
+ } else if ( (*p) > 57 ) {
794
+ if ( 65 <= (*p) && (*p) <= 90 )
795
+ goto st36;
796
+ } else
797
+ goto st36;
798
+ goto st0;
799
+ st36:
800
+ if ( ++p == pe )
801
+ goto _test_eof36;
802
+ case 36:
803
+ switch( (*p) ) {
804
+ case 32: goto tr2;
805
+ case 36: goto st37;
806
+ case 95: goto st37;
807
+ }
808
+ if ( (*p) < 48 ) {
809
+ if ( 45 <= (*p) && (*p) <= 46 )
810
+ goto st37;
811
+ } else if ( (*p) > 57 ) {
812
+ if ( 65 <= (*p) && (*p) <= 90 )
813
+ goto st37;
814
+ } else
815
+ goto st37;
816
+ goto st0;
817
+ st37:
818
+ if ( ++p == pe )
819
+ goto _test_eof37;
820
+ case 37:
821
+ switch( (*p) ) {
822
+ case 32: goto tr2;
823
+ case 36: goto st38;
824
+ case 95: goto st38;
825
+ }
826
+ if ( (*p) < 48 ) {
827
+ if ( 45 <= (*p) && (*p) <= 46 )
828
+ goto st38;
829
+ } else if ( (*p) > 57 ) {
830
+ if ( 65 <= (*p) && (*p) <= 90 )
831
+ goto st38;
832
+ } else
833
+ goto st38;
834
+ goto st0;
835
+ st38:
836
+ if ( ++p == pe )
837
+ goto _test_eof38;
838
+ case 38:
839
+ switch( (*p) ) {
840
+ case 32: goto tr2;
841
+ case 36: goto st39;
842
+ case 95: goto st39;
843
+ }
844
+ if ( (*p) < 48 ) {
845
+ if ( 45 <= (*p) && (*p) <= 46 )
846
+ goto st39;
847
+ } else if ( (*p) > 57 ) {
848
+ if ( 65 <= (*p) && (*p) <= 90 )
849
+ goto st39;
850
+ } else
851
+ goto st39;
852
+ goto st0;
853
+ st39:
854
+ if ( ++p == pe )
855
+ goto _test_eof39;
856
+ case 39:
857
+ switch( (*p) ) {
858
+ case 32: goto tr2;
859
+ case 36: goto st40;
860
+ case 95: goto st40;
861
+ }
862
+ if ( (*p) < 48 ) {
863
+ if ( 45 <= (*p) && (*p) <= 46 )
864
+ goto st40;
865
+ } else if ( (*p) > 57 ) {
866
+ if ( 65 <= (*p) && (*p) <= 90 )
867
+ goto st40;
868
+ } else
869
+ goto st40;
870
+ goto st0;
871
+ st40:
872
+ if ( ++p == pe )
873
+ goto _test_eof40;
874
+ case 40:
875
+ switch( (*p) ) {
876
+ case 32: goto tr2;
877
+ case 36: goto st41;
878
+ case 95: goto st41;
879
+ }
880
+ if ( (*p) < 48 ) {
881
+ if ( 45 <= (*p) && (*p) <= 46 )
882
+ goto st41;
883
+ } else if ( (*p) > 57 ) {
884
+ if ( 65 <= (*p) && (*p) <= 90 )
885
+ goto st41;
886
+ } else
887
+ goto st41;
888
+ goto st0;
889
+ st41:
890
+ if ( ++p == pe )
891
+ goto _test_eof41;
892
+ case 41:
893
+ switch( (*p) ) {
894
+ case 32: goto tr2;
895
+ case 36: goto st42;
896
+ case 95: goto st42;
897
+ }
898
+ if ( (*p) < 48 ) {
899
+ if ( 45 <= (*p) && (*p) <= 46 )
900
+ goto st42;
901
+ } else if ( (*p) > 57 ) {
902
+ if ( 65 <= (*p) && (*p) <= 90 )
903
+ goto st42;
904
+ } else
905
+ goto st42;
906
+ goto st0;
907
+ st42:
908
+ if ( ++p == pe )
909
+ goto _test_eof42;
910
+ case 42:
911
+ switch( (*p) ) {
912
+ case 32: goto tr2;
913
+ case 36: goto st43;
914
+ case 95: goto st43;
915
+ }
916
+ if ( (*p) < 48 ) {
917
+ if ( 45 <= (*p) && (*p) <= 46 )
918
+ goto st43;
919
+ } else if ( (*p) > 57 ) {
920
+ if ( 65 <= (*p) && (*p) <= 90 )
921
+ goto st43;
922
+ } else
923
+ goto st43;
924
+ goto st0;
925
+ st43:
926
+ if ( ++p == pe )
927
+ goto _test_eof43;
928
+ case 43:
929
+ switch( (*p) ) {
930
+ case 32: goto tr2;
931
+ case 36: goto st44;
932
+ case 95: goto st44;
933
+ }
934
+ if ( (*p) < 48 ) {
935
+ if ( 45 <= (*p) && (*p) <= 46 )
936
+ goto st44;
937
+ } else if ( (*p) > 57 ) {
938
+ if ( 65 <= (*p) && (*p) <= 90 )
939
+ goto st44;
940
+ } else
941
+ goto st44;
942
+ goto st0;
943
+ st44:
944
+ if ( ++p == pe )
945
+ goto _test_eof44;
946
+ case 44:
947
+ switch( (*p) ) {
948
+ case 32: goto tr2;
949
+ case 36: goto st45;
950
+ case 95: goto st45;
951
+ }
952
+ if ( (*p) < 48 ) {
953
+ if ( 45 <= (*p) && (*p) <= 46 )
954
+ goto st45;
955
+ } else if ( (*p) > 57 ) {
956
+ if ( 65 <= (*p) && (*p) <= 90 )
957
+ goto st45;
958
+ } else
959
+ goto st45;
960
+ goto st0;
961
+ st45:
962
+ if ( ++p == pe )
963
+ goto _test_eof45;
964
+ case 45:
965
+ switch( (*p) ) {
966
+ case 32: goto tr2;
967
+ case 36: goto st46;
968
+ case 95: goto st46;
969
+ }
970
+ if ( (*p) < 48 ) {
971
+ if ( 45 <= (*p) && (*p) <= 46 )
972
+ goto st46;
973
+ } else if ( (*p) > 57 ) {
974
+ if ( 65 <= (*p) && (*p) <= 90 )
975
+ goto st46;
976
+ } else
977
+ goto st46;
978
+ goto st0;
979
+ st46:
980
+ if ( ++p == pe )
981
+ goto _test_eof46;
982
+ case 46:
983
+ if ( (*p) == 32 )
984
+ goto tr2;
985
+ goto st0;
986
+ }
987
+ _test_eof2: cs = 2; goto _test_eof;
988
+ _test_eof3: cs = 3; goto _test_eof;
989
+ _test_eof4: cs = 4; goto _test_eof;
990
+ _test_eof5: cs = 5; goto _test_eof;
991
+ _test_eof6: cs = 6; goto _test_eof;
992
+ _test_eof7: cs = 7; goto _test_eof;
993
+ _test_eof8: cs = 8; goto _test_eof;
994
+ _test_eof9: cs = 9; goto _test_eof;
995
+ _test_eof10: cs = 10; goto _test_eof;
996
+ _test_eof11: cs = 11; goto _test_eof;
997
+ _test_eof12: cs = 12; goto _test_eof;
998
+ _test_eof13: cs = 13; goto _test_eof;
999
+ _test_eof14: cs = 14; goto _test_eof;
1000
+ _test_eof15: cs = 15; goto _test_eof;
1001
+ _test_eof16: cs = 16; goto _test_eof;
1002
+ _test_eof47: cs = 47; goto _test_eof;
1003
+ _test_eof17: cs = 17; goto _test_eof;
1004
+ _test_eof18: cs = 18; goto _test_eof;
1005
+ _test_eof19: cs = 19; goto _test_eof;
1006
+ _test_eof20: cs = 20; goto _test_eof;
1007
+ _test_eof21: cs = 21; goto _test_eof;
1008
+ _test_eof22: cs = 22; goto _test_eof;
1009
+ _test_eof23: cs = 23; goto _test_eof;
1010
+ _test_eof24: cs = 24; goto _test_eof;
1011
+ _test_eof25: cs = 25; goto _test_eof;
1012
+ _test_eof26: cs = 26; goto _test_eof;
1013
+ _test_eof27: cs = 27; goto _test_eof;
1014
+ _test_eof28: cs = 28; goto _test_eof;
1015
+ _test_eof29: cs = 29; goto _test_eof;
1016
+ _test_eof30: cs = 30; goto _test_eof;
1017
+ _test_eof31: cs = 31; goto _test_eof;
1018
+ _test_eof32: cs = 32; goto _test_eof;
1019
+ _test_eof33: cs = 33; goto _test_eof;
1020
+ _test_eof34: cs = 34; goto _test_eof;
1021
+ _test_eof35: cs = 35; goto _test_eof;
1022
+ _test_eof36: cs = 36; goto _test_eof;
1023
+ _test_eof37: cs = 37; goto _test_eof;
1024
+ _test_eof38: cs = 38; goto _test_eof;
1025
+ _test_eof39: cs = 39; goto _test_eof;
1026
+ _test_eof40: cs = 40; goto _test_eof;
1027
+ _test_eof41: cs = 41; goto _test_eof;
1028
+ _test_eof42: cs = 42; goto _test_eof;
1029
+ _test_eof43: cs = 43; goto _test_eof;
1030
+ _test_eof44: cs = 44; goto _test_eof;
1031
+ _test_eof45: cs = 45; goto _test_eof;
1032
+ _test_eof46: cs = 46; goto _test_eof;
1033
+
1034
+ _test_eof: {}
1035
+ _out: {}
1036
+ }
1037
+
1038
+ #line 115 "ext/puma_http11/http11_parser.rl"
1039
+
1040
+ if (!puma_parser_has_error(parser))
1041
+ parser->cs = cs;
1042
+ parser->nread += p - (buffer + off);
1043
+
1044
+ assert(p <= pe && "buffer overflow after parsing execute");
1045
+ assert(parser->nread <= len && "nread longer than length");
1046
+ assert(parser->body_start <= len && "body starts after buffer end");
1047
+ assert(parser->mark < len && "mark is after buffer end");
1048
+ assert(parser->field_len <= len && "field has length longer than whole buffer");
1049
+ assert(parser->field_start < len && "field starts after buffer end");
1050
+
1051
+ return(parser->nread);
1052
+ }
1053
+
1054
+ int puma_parser_finish(puma_parser *parser)
1055
+ {
1056
+ if (puma_parser_has_error(parser) ) {
1057
+ return -1;
1058
+ } else if (puma_parser_is_finished(parser) ) {
1059
+ return 1;
1060
+ } else {
1061
+ return 0;
1062
+ }
1063
+ }
1064
+
1065
+ int puma_parser_has_error(puma_parser *parser) {
1066
+ return parser->cs == puma_parser_error;
1067
+ }
1068
+
1069
+ int puma_parser_is_finished(puma_parser *parser) {
1070
+ return parser->cs >= puma_parser_first_final;
1071
+ }