puma 3.11.1 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/History.md +2092 -422
- data/LICENSE +23 -20
- data/README.md +301 -69
- data/bin/puma-wild +3 -9
- data/docs/architecture.md +59 -21
- data/docs/compile_options.md +55 -0
- data/docs/deployment.md +69 -58
- data/docs/fork_worker.md +41 -0
- data/docs/java_options.md +54 -0
- data/docs/jungle/README.md +9 -0
- data/docs/jungle/rc.d/README.md +74 -0
- data/docs/jungle/rc.d/puma +61 -0
- data/docs/jungle/rc.d/puma.conf +10 -0
- data/docs/kubernetes.md +78 -0
- data/docs/nginx.md +2 -2
- data/docs/plugins.md +26 -12
- data/docs/rails_dev_mode.md +28 -0
- data/docs/restart.md +48 -22
- data/docs/signals.md +13 -11
- data/docs/stats.md +147 -0
- data/docs/systemd.md +108 -117
- data/docs/testing_benchmarks_local_files.md +150 -0
- data/docs/testing_test_rackup_ci_files.md +36 -0
- data/ext/puma_http11/PumaHttp11Service.java +2 -2
- data/ext/puma_http11/ext_help.h +1 -1
- data/ext/puma_http11/extconf.rb +68 -3
- data/ext/puma_http11/http11_parser.c +106 -118
- data/ext/puma_http11/http11_parser.h +2 -2
- data/ext/puma_http11/http11_parser.java.rl +22 -38
- data/ext/puma_http11/http11_parser.rl +6 -4
- data/ext/puma_http11/http11_parser_common.rl +6 -6
- data/ext/puma_http11/mini_ssl.c +474 -94
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
- data/ext/puma_http11/org/jruby/puma/Http11.java +136 -121
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +84 -99
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +251 -88
- data/ext/puma_http11/puma_http11.c +53 -58
- data/lib/puma/app/status.rb +71 -49
- data/lib/puma/binder.rb +257 -151
- data/lib/puma/cli.rb +61 -38
- data/lib/puma/client.rb +464 -224
- data/lib/puma/cluster/worker.rb +183 -0
- data/lib/puma/cluster/worker_handle.rb +96 -0
- data/lib/puma/cluster.rb +343 -239
- data/lib/puma/commonlogger.rb +23 -14
- data/lib/puma/configuration.rb +144 -96
- data/lib/puma/const.rb +194 -115
- data/lib/puma/control_cli.rb +135 -81
- data/lib/puma/detect.rb +34 -2
- data/lib/puma/dsl.rb +1092 -153
- data/lib/puma/error_logger.rb +113 -0
- data/lib/puma/events.rb +17 -111
- data/lib/puma/io_buffer.rb +44 -5
- data/lib/puma/jruby_restart.rb +2 -73
- data/lib/puma/json_serialization.rb +96 -0
- data/lib/puma/launcher/bundle_pruner.rb +104 -0
- data/lib/puma/launcher.rb +205 -138
- data/lib/puma/log_writer.rb +147 -0
- data/lib/puma/minissl/context_builder.rb +96 -0
- data/lib/puma/minissl.rb +279 -70
- data/lib/puma/null_io.rb +61 -2
- data/lib/puma/plugin/systemd.rb +90 -0
- data/lib/puma/plugin/tmp_restart.rb +3 -1
- data/lib/puma/plugin.rb +9 -13
- data/lib/puma/rack/builder.rb +10 -11
- data/lib/puma/rack/urlmap.rb +3 -1
- data/lib/puma/rack_default.rb +21 -4
- data/lib/puma/reactor.rb +97 -185
- data/lib/puma/request.rb +688 -0
- data/lib/puma/runner.rb +114 -69
- data/lib/puma/sd_notify.rb +146 -0
- data/lib/puma/server.rb +409 -704
- data/lib/puma/single.rb +29 -72
- data/lib/puma/state_file.rb +48 -9
- data/lib/puma/thread_pool.rb +234 -93
- data/lib/puma/util.rb +23 -10
- data/lib/puma.rb +68 -5
- data/lib/rack/handler/puma.rb +119 -86
- data/tools/Dockerfile +16 -0
- data/tools/trickletest.rb +0 -1
- metadata +55 -33
- data/ext/puma_http11/io_buffer.c +0 -155
- data/lib/puma/accept_nonblock.rb +0 -23
- data/lib/puma/compat.rb +0 -14
- data/lib/puma/convenient.rb +0 -23
- data/lib/puma/daemon_ext.rb +0 -31
- data/lib/puma/delegation.rb +0 -11
- data/lib/puma/java_io_buffer.rb +0 -45
- data/lib/puma/rack/backports/uri/common_193.rb +0 -33
- data/lib/puma/tcp_logger.rb +0 -39
- data/tools/jungle/README.md +0 -13
- data/tools/jungle/init.d/README.md +0 -59
- data/tools/jungle/init.d/puma +0 -421
- data/tools/jungle/init.d/run-puma +0 -18
- data/tools/jungle/upstart/README.md +0 -61
- data/tools/jungle/upstart/puma-manager.conf +0 -31
- data/tools/jungle/upstart/puma.conf +0 -69
@@ -14,12 +14,14 @@
|
|
14
14
|
|
15
15
|
/*
|
16
16
|
* capitalizes all lower-case ASCII characters,
|
17
|
-
* converts dashes to underscores.
|
17
|
+
* converts dashes to underscores, and underscores to commas.
|
18
18
|
*/
|
19
19
|
static void snake_upcase_char(char *c)
|
20
20
|
{
|
21
21
|
if (*c >= 'a' && *c <= 'z')
|
22
22
|
*c &= ~0x20;
|
23
|
+
else if (*c == '_')
|
24
|
+
*c = ',';
|
23
25
|
else if (*c == '-')
|
24
26
|
*c = '_';
|
25
27
|
}
|
@@ -31,20 +33,18 @@ static void snake_upcase_char(char *c)
|
|
31
33
|
/** Machine **/
|
32
34
|
|
33
35
|
|
34
|
-
#line
|
36
|
+
#line 81 "ext/puma_http11/http11_parser.rl"
|
35
37
|
|
36
38
|
|
37
39
|
/** Data **/
|
38
40
|
|
39
|
-
#line
|
41
|
+
#line 42 "ext/puma_http11/http11_parser.c"
|
40
42
|
static const int puma_parser_start = 1;
|
41
|
-
static const int puma_parser_first_final =
|
43
|
+
static const int puma_parser_first_final = 46;
|
42
44
|
static const int puma_parser_error = 0;
|
43
45
|
|
44
|
-
static const int puma_parser_en_main = 1;
|
45
46
|
|
46
|
-
|
47
|
-
#line 83 "ext/puma_http11/http11_parser.rl"
|
47
|
+
#line 85 "ext/puma_http11/http11_parser.rl"
|
48
48
|
|
49
49
|
int puma_parser_init(puma_parser *parser) {
|
50
50
|
int cs = 0;
|
@@ -54,7 +54,7 @@ int puma_parser_init(puma_parser *parser) {
|
|
54
54
|
cs = puma_parser_start;
|
55
55
|
}
|
56
56
|
|
57
|
-
#line
|
57
|
+
#line 89 "ext/puma_http11/http11_parser.rl"
|
58
58
|
parser->cs = cs;
|
59
59
|
parser->body_start = 0;
|
60
60
|
parser->content_len = 0;
|
@@ -107,7 +107,7 @@ st0:
|
|
107
107
|
cs = 0;
|
108
108
|
goto _out;
|
109
109
|
tr0:
|
110
|
-
#line
|
110
|
+
#line 37 "ext/puma_http11/http11_parser.rl"
|
111
111
|
{ MARK(mark, p); }
|
112
112
|
goto st2;
|
113
113
|
st2:
|
@@ -117,20 +117,20 @@ case 2:
|
|
117
117
|
#line 118 "ext/puma_http11/http11_parser.c"
|
118
118
|
switch( (*p) ) {
|
119
119
|
case 32: goto tr2;
|
120
|
-
case 36: goto
|
121
|
-
case 95: goto
|
120
|
+
case 36: goto st27;
|
121
|
+
case 95: goto st27;
|
122
122
|
}
|
123
123
|
if ( (*p) < 48 ) {
|
124
124
|
if ( 45 <= (*p) && (*p) <= 46 )
|
125
|
-
goto
|
125
|
+
goto st27;
|
126
126
|
} else if ( (*p) > 57 ) {
|
127
127
|
if ( 65 <= (*p) && (*p) <= 90 )
|
128
|
-
goto
|
128
|
+
goto st27;
|
129
129
|
} else
|
130
|
-
goto
|
130
|
+
goto st27;
|
131
131
|
goto st0;
|
132
132
|
tr2:
|
133
|
-
#line
|
133
|
+
#line 50 "ext/puma_http11/http11_parser.rl"
|
134
134
|
{
|
135
135
|
parser->request_method(parser, PTR_TO(mark), LEN(mark, p));
|
136
136
|
}
|
@@ -156,7 +156,7 @@ case 3:
|
|
156
156
|
goto tr5;
|
157
157
|
goto st0;
|
158
158
|
tr4:
|
159
|
-
#line
|
159
|
+
#line 37 "ext/puma_http11/http11_parser.rl"
|
160
160
|
{ MARK(mark, p); }
|
161
161
|
goto st4;
|
162
162
|
st4:
|
@@ -170,53 +170,53 @@ case 4:
|
|
170
170
|
}
|
171
171
|
goto st0;
|
172
172
|
tr8:
|
173
|
-
#line
|
173
|
+
#line 53 "ext/puma_http11/http11_parser.rl"
|
174
174
|
{
|
175
175
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
176
176
|
}
|
177
177
|
goto st5;
|
178
178
|
tr31:
|
179
|
-
#line
|
179
|
+
#line 37 "ext/puma_http11/http11_parser.rl"
|
180
180
|
{ MARK(mark, p); }
|
181
|
-
#line
|
181
|
+
#line 56 "ext/puma_http11/http11_parser.rl"
|
182
182
|
{
|
183
183
|
parser->fragment(parser, PTR_TO(mark), LEN(mark, p));
|
184
184
|
}
|
185
185
|
goto st5;
|
186
186
|
tr33:
|
187
|
-
#line
|
187
|
+
#line 56 "ext/puma_http11/http11_parser.rl"
|
188
188
|
{
|
189
189
|
parser->fragment(parser, PTR_TO(mark), LEN(mark, p));
|
190
190
|
}
|
191
191
|
goto st5;
|
192
192
|
tr37:
|
193
|
-
#line
|
193
|
+
#line 69 "ext/puma_http11/http11_parser.rl"
|
194
194
|
{
|
195
195
|
parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
|
196
196
|
}
|
197
|
-
#line
|
197
|
+
#line 53 "ext/puma_http11/http11_parser.rl"
|
198
198
|
{
|
199
199
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
200
200
|
}
|
201
201
|
goto st5;
|
202
|
-
|
203
|
-
#line
|
202
|
+
tr41:
|
203
|
+
#line 60 "ext/puma_http11/http11_parser.rl"
|
204
204
|
{ MARK(query_start, p); }
|
205
|
-
#line
|
205
|
+
#line 61 "ext/puma_http11/http11_parser.rl"
|
206
206
|
{
|
207
207
|
parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
|
208
208
|
}
|
209
|
-
#line
|
209
|
+
#line 53 "ext/puma_http11/http11_parser.rl"
|
210
210
|
{
|
211
211
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
212
212
|
}
|
213
213
|
goto st5;
|
214
|
-
|
215
|
-
#line
|
214
|
+
tr44:
|
215
|
+
#line 61 "ext/puma_http11/http11_parser.rl"
|
216
216
|
{
|
217
217
|
parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
|
218
218
|
}
|
219
|
-
#line
|
219
|
+
#line 53 "ext/puma_http11/http11_parser.rl"
|
220
220
|
{
|
221
221
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
222
222
|
}
|
@@ -230,7 +230,7 @@ case 5:
|
|
230
230
|
goto tr10;
|
231
231
|
goto st0;
|
232
232
|
tr10:
|
233
|
-
#line
|
233
|
+
#line 37 "ext/puma_http11/http11_parser.rl"
|
234
234
|
{ MARK(mark, p); }
|
235
235
|
goto st6;
|
236
236
|
st6:
|
@@ -295,21 +295,21 @@ case 13:
|
|
295
295
|
goto st13;
|
296
296
|
goto st0;
|
297
297
|
tr18:
|
298
|
-
#line
|
298
|
+
#line 65 "ext/puma_http11/http11_parser.rl"
|
299
299
|
{
|
300
|
-
parser->
|
300
|
+
parser->server_protocol(parser, PTR_TO(mark), LEN(mark, p));
|
301
301
|
}
|
302
302
|
goto st14;
|
303
303
|
tr26:
|
304
|
-
#line
|
304
|
+
#line 46 "ext/puma_http11/http11_parser.rl"
|
305
305
|
{ MARK(mark, p); }
|
306
|
-
#line
|
306
|
+
#line 47 "ext/puma_http11/http11_parser.rl"
|
307
307
|
{
|
308
308
|
parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
|
309
309
|
}
|
310
310
|
goto st14;
|
311
311
|
tr29:
|
312
|
-
#line
|
312
|
+
#line 47 "ext/puma_http11/http11_parser.rl"
|
313
313
|
{
|
314
314
|
parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
|
315
315
|
}
|
@@ -358,27 +358,27 @@ case 16:
|
|
358
358
|
goto tr22;
|
359
359
|
goto st0;
|
360
360
|
tr22:
|
361
|
-
#line
|
361
|
+
#line 73 "ext/puma_http11/http11_parser.rl"
|
362
362
|
{
|
363
363
|
parser->body_start = p - buffer + 1;
|
364
364
|
parser->header_done(parser, p + 1, pe - p - 1);
|
365
|
-
{p++; cs =
|
365
|
+
{p++; cs = 46; goto _out;}
|
366
366
|
}
|
367
|
-
goto
|
368
|
-
|
367
|
+
goto st46;
|
368
|
+
st46:
|
369
369
|
if ( ++p == pe )
|
370
|
-
goto
|
371
|
-
case
|
370
|
+
goto _test_eof46;
|
371
|
+
case 46:
|
372
372
|
#line 373 "ext/puma_http11/http11_parser.c"
|
373
373
|
goto st0;
|
374
374
|
tr21:
|
375
|
-
#line
|
375
|
+
#line 40 "ext/puma_http11/http11_parser.rl"
|
376
376
|
{ MARK(field_start, p); }
|
377
|
-
#line
|
377
|
+
#line 41 "ext/puma_http11/http11_parser.rl"
|
378
378
|
{ snake_upcase_char((char *)p); }
|
379
379
|
goto st17;
|
380
380
|
tr23:
|
381
|
-
#line
|
381
|
+
#line 41 "ext/puma_http11/http11_parser.rl"
|
382
382
|
{ snake_upcase_char((char *)p); }
|
383
383
|
goto st17;
|
384
384
|
st17:
|
@@ -411,13 +411,13 @@ case 17:
|
|
411
411
|
goto tr23;
|
412
412
|
goto st0;
|
413
413
|
tr24:
|
414
|
-
#line
|
414
|
+
#line 42 "ext/puma_http11/http11_parser.rl"
|
415
415
|
{
|
416
416
|
parser->field_len = LEN(field_start, p);
|
417
417
|
}
|
418
418
|
goto st18;
|
419
419
|
tr27:
|
420
|
-
#line
|
420
|
+
#line 46 "ext/puma_http11/http11_parser.rl"
|
421
421
|
{ MARK(mark, p); }
|
422
422
|
goto st18;
|
423
423
|
st18:
|
@@ -428,54 +428,67 @@ case 18:
|
|
428
428
|
switch( (*p) ) {
|
429
429
|
case 13: goto tr26;
|
430
430
|
case 32: goto tr27;
|
431
|
+
case 127: goto st0;
|
431
432
|
}
|
433
|
+
if ( (*p) > 8 ) {
|
434
|
+
if ( 10 <= (*p) && (*p) <= 31 )
|
435
|
+
goto st0;
|
436
|
+
} else if ( (*p) >= 0 )
|
437
|
+
goto st0;
|
432
438
|
goto tr25;
|
433
439
|
tr25:
|
434
|
-
#line
|
440
|
+
#line 46 "ext/puma_http11/http11_parser.rl"
|
435
441
|
{ MARK(mark, p); }
|
436
442
|
goto st19;
|
437
443
|
st19:
|
438
444
|
if ( ++p == pe )
|
439
445
|
goto _test_eof19;
|
440
446
|
case 19:
|
441
|
-
#line
|
442
|
-
|
443
|
-
goto tr29;
|
447
|
+
#line 448 "ext/puma_http11/http11_parser.c"
|
448
|
+
switch( (*p) ) {
|
449
|
+
case 13: goto tr29;
|
450
|
+
case 127: goto st0;
|
451
|
+
}
|
452
|
+
if ( (*p) > 8 ) {
|
453
|
+
if ( 10 <= (*p) && (*p) <= 31 )
|
454
|
+
goto st0;
|
455
|
+
} else if ( (*p) >= 0 )
|
456
|
+
goto st0;
|
444
457
|
goto st19;
|
445
458
|
tr9:
|
446
|
-
#line
|
459
|
+
#line 53 "ext/puma_http11/http11_parser.rl"
|
447
460
|
{
|
448
461
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
449
462
|
}
|
450
463
|
goto st20;
|
451
464
|
tr38:
|
452
|
-
#line
|
465
|
+
#line 69 "ext/puma_http11/http11_parser.rl"
|
453
466
|
{
|
454
467
|
parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
|
455
468
|
}
|
456
|
-
#line
|
469
|
+
#line 53 "ext/puma_http11/http11_parser.rl"
|
457
470
|
{
|
458
471
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
459
472
|
}
|
460
473
|
goto st20;
|
461
|
-
|
462
|
-
#line
|
474
|
+
tr42:
|
475
|
+
#line 60 "ext/puma_http11/http11_parser.rl"
|
463
476
|
{ MARK(query_start, p); }
|
464
|
-
#line
|
477
|
+
#line 61 "ext/puma_http11/http11_parser.rl"
|
465
478
|
{
|
466
479
|
parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
|
467
480
|
}
|
468
|
-
#line
|
481
|
+
#line 53 "ext/puma_http11/http11_parser.rl"
|
469
482
|
{
|
470
483
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
471
484
|
}
|
472
485
|
goto st20;
|
473
|
-
|
474
|
-
#line
|
486
|
+
tr45:
|
487
|
+
#line 61 "ext/puma_http11/http11_parser.rl"
|
475
488
|
{
|
476
489
|
parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
|
477
490
|
}
|
478
|
-
#line
|
491
|
+
#line 53 "ext/puma_http11/http11_parser.rl"
|
479
492
|
{
|
480
493
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
481
494
|
}
|
@@ -484,7 +497,7 @@ st20:
|
|
484
497
|
if ( ++p == pe )
|
485
498
|
goto _test_eof20;
|
486
499
|
case 20:
|
487
|
-
#line
|
500
|
+
#line 501 "ext/puma_http11/http11_parser.c"
|
488
501
|
switch( (*p) ) {
|
489
502
|
case 32: goto tr31;
|
490
503
|
case 60: goto st0;
|
@@ -498,14 +511,14 @@ case 20:
|
|
498
511
|
goto st0;
|
499
512
|
goto tr30;
|
500
513
|
tr30:
|
501
|
-
#line
|
514
|
+
#line 37 "ext/puma_http11/http11_parser.rl"
|
502
515
|
{ MARK(mark, p); }
|
503
516
|
goto st21;
|
504
517
|
st21:
|
505
518
|
if ( ++p == pe )
|
506
519
|
goto _test_eof21;
|
507
520
|
case 21:
|
508
|
-
#line
|
521
|
+
#line 522 "ext/puma_http11/http11_parser.c"
|
509
522
|
switch( (*p) ) {
|
510
523
|
case 32: goto tr33;
|
511
524
|
case 60: goto st0;
|
@@ -519,14 +532,14 @@ case 21:
|
|
519
532
|
goto st0;
|
520
533
|
goto st21;
|
521
534
|
tr5:
|
522
|
-
#line
|
535
|
+
#line 37 "ext/puma_http11/http11_parser.rl"
|
523
536
|
{ MARK(mark, p); }
|
524
537
|
goto st22;
|
525
538
|
st22:
|
526
539
|
if ( ++p == pe )
|
527
540
|
goto _test_eof22;
|
528
541
|
case 22:
|
529
|
-
#line
|
542
|
+
#line 543 "ext/puma_http11/http11_parser.c"
|
530
543
|
switch( (*p) ) {
|
531
544
|
case 43: goto st22;
|
532
545
|
case 58: goto st23;
|
@@ -544,14 +557,14 @@ case 22:
|
|
544
557
|
goto st22;
|
545
558
|
goto st0;
|
546
559
|
tr7:
|
547
|
-
#line
|
560
|
+
#line 37 "ext/puma_http11/http11_parser.rl"
|
548
561
|
{ MARK(mark, p); }
|
549
562
|
goto st23;
|
550
563
|
st23:
|
551
564
|
if ( ++p == pe )
|
552
565
|
goto _test_eof23;
|
553
566
|
case 23:
|
554
|
-
#line
|
567
|
+
#line 568 "ext/puma_http11/http11_parser.c"
|
555
568
|
switch( (*p) ) {
|
556
569
|
case 32: goto tr8;
|
557
570
|
case 34: goto st0;
|
@@ -564,29 +577,28 @@ case 23:
|
|
564
577
|
goto st0;
|
565
578
|
goto st23;
|
566
579
|
tr6:
|
567
|
-
#line
|
580
|
+
#line 37 "ext/puma_http11/http11_parser.rl"
|
568
581
|
{ MARK(mark, p); }
|
569
582
|
goto st24;
|
570
583
|
st24:
|
571
584
|
if ( ++p == pe )
|
572
585
|
goto _test_eof24;
|
573
586
|
case 24:
|
574
|
-
#line
|
587
|
+
#line 588 "ext/puma_http11/http11_parser.c"
|
575
588
|
switch( (*p) ) {
|
576
589
|
case 32: goto tr37;
|
577
590
|
case 34: goto st0;
|
578
591
|
case 35: goto tr38;
|
579
|
-
case 59: goto tr39;
|
580
592
|
case 60: goto st0;
|
581
593
|
case 62: goto st0;
|
582
|
-
case 63: goto
|
594
|
+
case 63: goto tr39;
|
583
595
|
case 127: goto st0;
|
584
596
|
}
|
585
597
|
if ( 0 <= (*p) && (*p) <= 31 )
|
586
598
|
goto st0;
|
587
599
|
goto st24;
|
588
600
|
tr39:
|
589
|
-
#line
|
601
|
+
#line 69 "ext/puma_http11/http11_parser.rl"
|
590
602
|
{
|
591
603
|
parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
|
592
604
|
}
|
@@ -595,30 +607,27 @@ st25:
|
|
595
607
|
if ( ++p == pe )
|
596
608
|
goto _test_eof25;
|
597
609
|
case 25:
|
598
|
-
#line
|
610
|
+
#line 611 "ext/puma_http11/http11_parser.c"
|
599
611
|
switch( (*p) ) {
|
600
|
-
case 32: goto
|
612
|
+
case 32: goto tr41;
|
601
613
|
case 34: goto st0;
|
602
|
-
case 35: goto
|
614
|
+
case 35: goto tr42;
|
603
615
|
case 60: goto st0;
|
604
616
|
case 62: goto st0;
|
605
|
-
case 63: goto st26;
|
606
617
|
case 127: goto st0;
|
607
618
|
}
|
608
619
|
if ( 0 <= (*p) && (*p) <= 31 )
|
609
620
|
goto st0;
|
610
|
-
goto
|
621
|
+
goto tr40;
|
611
622
|
tr40:
|
612
|
-
#line
|
613
|
-
{
|
614
|
-
parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
|
615
|
-
}
|
623
|
+
#line 60 "ext/puma_http11/http11_parser.rl"
|
624
|
+
{ MARK(query_start, p); }
|
616
625
|
goto st26;
|
617
626
|
st26:
|
618
627
|
if ( ++p == pe )
|
619
628
|
goto _test_eof26;
|
620
629
|
case 26:
|
621
|
-
#line
|
630
|
+
#line 631 "ext/puma_http11/http11_parser.c"
|
622
631
|
switch( (*p) ) {
|
623
632
|
case 32: goto tr44;
|
624
633
|
case 34: goto st0;
|
@@ -629,27 +638,25 @@ case 26:
|
|
629
638
|
}
|
630
639
|
if ( 0 <= (*p) && (*p) <= 31 )
|
631
640
|
goto st0;
|
632
|
-
goto
|
633
|
-
tr43:
|
634
|
-
#line 58 "ext/puma_http11/http11_parser.rl"
|
635
|
-
{ MARK(query_start, p); }
|
636
|
-
goto st27;
|
641
|
+
goto st26;
|
637
642
|
st27:
|
638
643
|
if ( ++p == pe )
|
639
644
|
goto _test_eof27;
|
640
645
|
case 27:
|
641
|
-
#line 642 "ext/puma_http11/http11_parser.c"
|
642
646
|
switch( (*p) ) {
|
643
|
-
case 32: goto
|
644
|
-
case
|
645
|
-
case
|
646
|
-
case 60: goto st0;
|
647
|
-
case 62: goto st0;
|
648
|
-
case 127: goto st0;
|
647
|
+
case 32: goto tr2;
|
648
|
+
case 36: goto st28;
|
649
|
+
case 95: goto st28;
|
649
650
|
}
|
650
|
-
if (
|
651
|
-
|
652
|
-
|
651
|
+
if ( (*p) < 48 ) {
|
652
|
+
if ( 45 <= (*p) && (*p) <= 46 )
|
653
|
+
goto st28;
|
654
|
+
} else if ( (*p) > 57 ) {
|
655
|
+
if ( 65 <= (*p) && (*p) <= 90 )
|
656
|
+
goto st28;
|
657
|
+
} else
|
658
|
+
goto st28;
|
659
|
+
goto st0;
|
653
660
|
st28:
|
654
661
|
if ( ++p == pe )
|
655
662
|
goto _test_eof28;
|
@@ -960,24 +967,6 @@ st45:
|
|
960
967
|
if ( ++p == pe )
|
961
968
|
goto _test_eof45;
|
962
969
|
case 45:
|
963
|
-
switch( (*p) ) {
|
964
|
-
case 32: goto tr2;
|
965
|
-
case 36: goto st46;
|
966
|
-
case 95: goto st46;
|
967
|
-
}
|
968
|
-
if ( (*p) < 48 ) {
|
969
|
-
if ( 45 <= (*p) && (*p) <= 46 )
|
970
|
-
goto st46;
|
971
|
-
} else if ( (*p) > 57 ) {
|
972
|
-
if ( 65 <= (*p) && (*p) <= 90 )
|
973
|
-
goto st46;
|
974
|
-
} else
|
975
|
-
goto st46;
|
976
|
-
goto st0;
|
977
|
-
st46:
|
978
|
-
if ( ++p == pe )
|
979
|
-
goto _test_eof46;
|
980
|
-
case 46:
|
981
970
|
if ( (*p) == 32 )
|
982
971
|
goto tr2;
|
983
972
|
goto st0;
|
@@ -997,7 +986,7 @@ case 46:
|
|
997
986
|
_test_eof14: cs = 14; goto _test_eof;
|
998
987
|
_test_eof15: cs = 15; goto _test_eof;
|
999
988
|
_test_eof16: cs = 16; goto _test_eof;
|
1000
|
-
|
989
|
+
_test_eof46: cs = 46; goto _test_eof;
|
1001
990
|
_test_eof17: cs = 17; goto _test_eof;
|
1002
991
|
_test_eof18: cs = 18; goto _test_eof;
|
1003
992
|
_test_eof19: cs = 19; goto _test_eof;
|
@@ -1027,13 +1016,12 @@ case 46:
|
|
1027
1016
|
_test_eof43: cs = 43; goto _test_eof;
|
1028
1017
|
_test_eof44: cs = 44; goto _test_eof;
|
1029
1018
|
_test_eof45: cs = 45; goto _test_eof;
|
1030
|
-
_test_eof46: cs = 46; goto _test_eof;
|
1031
1019
|
|
1032
1020
|
_test_eof: {}
|
1033
1021
|
_out: {}
|
1034
1022
|
}
|
1035
1023
|
|
1036
|
-
#line
|
1024
|
+
#line 117 "ext/puma_http11/http11_parser.rl"
|
1037
1025
|
|
1038
1026
|
if (!puma_parser_has_error(parser))
|
1039
1027
|
parser->cs = cs;
|
@@ -29,8 +29,8 @@ typedef void (*field_cb)(struct puma_parser* hp,
|
|
29
29
|
|
30
30
|
typedef struct puma_parser {
|
31
31
|
int cs;
|
32
|
-
size_t body_start;
|
33
32
|
int content_len;
|
33
|
+
size_t body_start;
|
34
34
|
size_t nread;
|
35
35
|
size_t mark;
|
36
36
|
size_t field_start;
|
@@ -46,7 +46,7 @@ typedef struct puma_parser {
|
|
46
46
|
element_cb fragment;
|
47
47
|
element_cb request_path;
|
48
48
|
element_cb query_string;
|
49
|
-
element_cb
|
49
|
+
element_cb server_protocol;
|
50
50
|
element_cb header_done;
|
51
51
|
|
52
52
|
char buf[BUFFER_LEN];
|
@@ -1,5 +1,7 @@
|
|
1
1
|
package org.jruby.puma;
|
2
2
|
|
3
|
+
import org.jruby.Ruby;
|
4
|
+
import org.jruby.RubyHash;
|
3
5
|
import org.jruby.util.ByteList;
|
4
6
|
|
5
7
|
public class Http11Parser {
|
@@ -19,44 +21,35 @@ public class Http11Parser {
|
|
19
21
|
}
|
20
22
|
|
21
23
|
action start_value { parser.mark = fpc; }
|
22
|
-
action write_value {
|
23
|
-
|
24
|
-
parser.http_field.call(parser.data, parser.field_start, parser.field_len, parser.mark, fpc-parser.mark);
|
25
|
-
}
|
24
|
+
action write_value {
|
25
|
+
Http11.http_field(runtime, parser.data, parser.buffer, parser.field_start, parser.field_len, parser.mark, fpc-parser.mark);
|
26
26
|
}
|
27
|
-
action request_method {
|
28
|
-
|
29
|
-
parser.request_method.call(parser.data, parser.mark, fpc-parser.mark);
|
27
|
+
action request_method {
|
28
|
+
Http11.request_method(runtime, parser.data, parser.buffer, parser.mark, fpc-parser.mark);
|
30
29
|
}
|
31
|
-
action request_uri {
|
32
|
-
|
33
|
-
parser.request_uri.call(parser.data, parser.mark, fpc-parser.mark);
|
30
|
+
action request_uri {
|
31
|
+
Http11.request_uri(runtime, parser.data, parser.buffer, parser.mark, fpc-parser.mark);
|
34
32
|
}
|
35
|
-
action fragment {
|
36
|
-
|
37
|
-
parser.fragment.call(parser.data, parser.mark, fpc-parser.mark);
|
33
|
+
action fragment {
|
34
|
+
Http11.fragment(runtime, parser.data, parser.buffer, parser.mark, fpc-parser.mark);
|
38
35
|
}
|
39
36
|
|
40
37
|
action start_query {parser.query_start = fpc; }
|
41
|
-
action query_string {
|
42
|
-
|
43
|
-
parser.query_string.call(parser.data, parser.query_start, fpc-parser.query_start);
|
38
|
+
action query_string {
|
39
|
+
Http11.query_string(runtime, parser.data, parser.buffer, parser.query_start, fpc-parser.query_start);
|
44
40
|
}
|
45
41
|
|
46
|
-
action
|
47
|
-
|
48
|
-
parser.http_version.call(parser.data, parser.mark, fpc-parser.mark);
|
42
|
+
action server_protocol {
|
43
|
+
Http11.server_protocol(runtime, parser.data, parser.buffer, parser.mark, fpc-parser.mark);
|
49
44
|
}
|
50
45
|
|
51
46
|
action request_path {
|
52
|
-
|
53
|
-
parser.request_path.call(parser.data, parser.mark, fpc-parser.mark);
|
47
|
+
Http11.request_path(runtime, parser.data, parser.buffer, parser.mark, fpc-parser.mark);
|
54
48
|
}
|
55
49
|
|
56
50
|
action done {
|
57
|
-
parser.body_start = fpc + 1;
|
58
|
-
|
59
|
-
parser.header_done.call(parser.data, fpc + 1, pe - fpc - 1);
|
51
|
+
parser.body_start = fpc + 1;
|
52
|
+
http.header_done(runtime, parser.data, parser.buffer, fpc + 1, pe - fpc - 1);
|
60
53
|
fbreak;
|
61
54
|
}
|
62
55
|
|
@@ -65,14 +58,14 @@ public class Http11Parser {
|
|
65
58
|
}%%
|
66
59
|
|
67
60
|
/** Data **/
|
68
|
-
%% write data;
|
61
|
+
%% write data noentry;
|
69
62
|
|
70
63
|
public static interface ElementCB {
|
71
|
-
public void call(
|
64
|
+
public void call(Ruby runtime, RubyHash data, ByteList buffer, int at, int length);
|
72
65
|
}
|
73
66
|
|
74
67
|
public static interface FieldCB {
|
75
|
-
public void call(
|
68
|
+
public void call(Ruby runtime, RubyHash data, ByteList buffer, int field, int flen, int value, int vlen);
|
76
69
|
}
|
77
70
|
|
78
71
|
public static class HttpParser {
|
@@ -85,18 +78,9 @@ public class Http11Parser {
|
|
85
78
|
int field_len;
|
86
79
|
int query_start;
|
87
80
|
|
88
|
-
|
81
|
+
RubyHash data;
|
89
82
|
ByteList buffer;
|
90
83
|
|
91
|
-
public FieldCB http_field;
|
92
|
-
public ElementCB request_method;
|
93
|
-
public ElementCB request_uri;
|
94
|
-
public ElementCB fragment;
|
95
|
-
public ElementCB request_path;
|
96
|
-
public ElementCB query_string;
|
97
|
-
public ElementCB http_version;
|
98
|
-
public ElementCB header_done;
|
99
|
-
|
100
84
|
public void init() {
|
101
85
|
cs = 0;
|
102
86
|
|
@@ -113,7 +97,7 @@ public class Http11Parser {
|
|
113
97
|
|
114
98
|
public final HttpParser parser = new HttpParser();
|
115
99
|
|
116
|
-
public int execute(ByteList buffer, int off) {
|
100
|
+
public int execute(Ruby runtime, Http11 http, ByteList buffer, int off) {
|
117
101
|
int p, pe;
|
118
102
|
int cs = parser.cs;
|
119
103
|
int len = buffer.length();
|