puma 8.1.4 → 8.2.0.pre1

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +114 -19
  3. data/README.md +4 -3
  4. data/docs/GLOSSARY.md +160 -0
  5. data/docs/architecture.md +41 -42
  6. data/docs/binding.md +3 -0
  7. data/docs/cluster_mode.md +21 -21
  8. data/docs/control_server.md +4 -4
  9. data/docs/deployment/nginx.md +2 -0
  10. data/docs/deployment/systemd.md +15 -0
  11. data/docs/puma_support.md +12 -0
  12. data/docs/restart.md +2 -2
  13. data/docs/signals.md +3 -3
  14. data/docs/ssl.md +65 -0
  15. data/docs/upgrading/5.0-Upgrade.md +1 -1
  16. data/docs/upgrading/6.0-Upgrade.md +1 -1
  17. data/docs/upgrading/7.0-Upgrade.md +1 -1
  18. data/docs/upgrading/8.0-Upgrade.md +1 -1
  19. data/ext/puma_http11/extconf.rb +7 -5
  20. data/ext/puma_http11/http11_parser.c +66 -84
  21. data/ext/puma_http11/http11_parser.h +0 -5
  22. data/ext/puma_http11/mini_ssl.c +17 -61
  23. data/ext/puma_http11/puma_http11.c +125 -7
  24. data/lib/puma/app/status.rb +22 -7
  25. data/lib/puma/binder.rb +0 -1
  26. data/lib/puma/cli.rb +1 -3
  27. data/lib/puma/client.rb +114 -56
  28. data/lib/puma/client_env.rb +9 -11
  29. data/lib/puma/cluster/worker.rb +0 -6
  30. data/lib/puma/cluster.rb +3 -14
  31. data/lib/puma/cluster_accept_loop_delay.rb +18 -7
  32. data/lib/puma/commonlogger.rb +3 -4
  33. data/lib/puma/configuration.rb +4 -1
  34. data/lib/puma/const.rb +5 -5
  35. data/lib/puma/control_cli.rb +5 -7
  36. data/lib/puma/detect.rb +1 -1
  37. data/lib/puma/dsl.rb +70 -14
  38. data/lib/puma/http_parser_error.rb +8 -0
  39. data/lib/puma/launcher/bundle_pruner.rb +3 -21
  40. data/lib/puma/launcher.rb +13 -5
  41. data/lib/puma/minissl/context_builder.rb +3 -2
  42. data/lib/puma/minissl.rb +3 -12
  43. data/lib/puma/plugin/systemd.rb +69 -3
  44. data/lib/puma/rack/urlmap.rb +2 -2
  45. data/lib/puma/reactor.rb +138 -25
  46. data/lib/puma/response.rb +52 -33
  47. data/lib/puma/runner.rb +4 -1
  48. data/lib/puma/sd_notify.rb +21 -0
  49. data/lib/puma/server.rb +14 -14
  50. data/lib/puma/single.rb +0 -1
  51. data/lib/puma/thread_pool.rb +87 -14
  52. data/lib/puma/util.rb +5 -16
  53. data/lib/puma.rb +22 -5
  54. data/lib/rack/handler/puma.rb +1 -5
  55. metadata +4 -1
@@ -12,20 +12,6 @@
12
12
  #include <ctype.h>
13
13
  #include <string.h>
14
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
15
  #define LEN(AT, FPC) (FPC - buffer - parser->AT)
30
16
  #define MARK(M,FPC) (parser->M = (FPC) - buffer)
31
17
  #define PTR_TO(F) (buffer + parser->F)
@@ -33,28 +19,28 @@ static void snake_upcase_char(char *c)
33
19
  /** Machine **/
34
20
 
35
21
 
36
- #line 81 "ext/puma_http11/http11_parser.rl"
22
+ #line 67 "ext/puma_http11/http11_parser.rl"
37
23
 
38
24
 
39
25
  /** Data **/
40
26
 
41
- #line 42 "ext/puma_http11/http11_parser.c"
27
+ #line 28 "ext/puma_http11/http11_parser.c"
42
28
  static const int puma_parser_start = 1;
43
29
  static const int puma_parser_first_final = 46;
44
30
  static const int puma_parser_error = 0;
45
31
 
46
32
 
47
- #line 85 "ext/puma_http11/http11_parser.rl"
33
+ #line 71 "ext/puma_http11/http11_parser.rl"
48
34
 
49
35
  int puma_parser_init(puma_parser *parser) {
50
36
  int cs = 0;
51
37
 
52
- #line 53 "ext/puma_http11/http11_parser.c"
38
+ #line 39 "ext/puma_http11/http11_parser.c"
53
39
  {
54
40
  cs = puma_parser_start;
55
41
  }
56
42
 
57
- #line 89 "ext/puma_http11/http11_parser.rl"
43
+ #line 75 "ext/puma_http11/http11_parser.rl"
58
44
  parser->cs = cs;
59
45
  parser->body_start = 0;
60
46
  parser->content_len = 0;
@@ -83,7 +69,7 @@ size_t puma_parser_execute(puma_parser *parser, const char *buffer, size_t len,
83
69
  assert((size_t) (pe - p) == len - off && "pointers aren't same distance");
84
70
 
85
71
 
86
- #line 87 "ext/puma_http11/http11_parser.c"
72
+ #line 73 "ext/puma_http11/http11_parser.c"
87
73
  {
88
74
  if ( p == pe )
89
75
  goto _test_eof;
@@ -107,14 +93,14 @@ st0:
107
93
  cs = 0;
108
94
  goto _out;
109
95
  tr0:
110
- #line 37 "ext/puma_http11/http11_parser.rl"
96
+ #line 23 "ext/puma_http11/http11_parser.rl"
111
97
  { MARK(mark, p); }
112
98
  goto st2;
113
99
  st2:
114
100
  if ( ++p == pe )
115
101
  goto _test_eof2;
116
102
  case 2:
117
- #line 118 "ext/puma_http11/http11_parser.c"
103
+ #line 104 "ext/puma_http11/http11_parser.c"
118
104
  switch( (*p) ) {
119
105
  case 32: goto tr2;
120
106
  case 36: goto st27;
@@ -130,7 +116,7 @@ case 2:
130
116
  goto st27;
131
117
  goto st0;
132
118
  tr2:
133
- #line 50 "ext/puma_http11/http11_parser.rl"
119
+ #line 36 "ext/puma_http11/http11_parser.rl"
134
120
  {
135
121
  parser->request_method(parser, PTR_TO(mark), LEN(mark, p));
136
122
  }
@@ -139,7 +125,7 @@ st3:
139
125
  if ( ++p == pe )
140
126
  goto _test_eof3;
141
127
  case 3:
142
- #line 143 "ext/puma_http11/http11_parser.c"
128
+ #line 129 "ext/puma_http11/http11_parser.c"
143
129
  switch( (*p) ) {
144
130
  case 42: goto tr4;
145
131
  case 43: goto tr5;
@@ -156,67 +142,67 @@ case 3:
156
142
  goto tr5;
157
143
  goto st0;
158
144
  tr4:
159
- #line 37 "ext/puma_http11/http11_parser.rl"
145
+ #line 23 "ext/puma_http11/http11_parser.rl"
160
146
  { MARK(mark, p); }
161
147
  goto st4;
162
148
  st4:
163
149
  if ( ++p == pe )
164
150
  goto _test_eof4;
165
151
  case 4:
166
- #line 167 "ext/puma_http11/http11_parser.c"
152
+ #line 153 "ext/puma_http11/http11_parser.c"
167
153
  switch( (*p) ) {
168
154
  case 32: goto tr8;
169
155
  case 35: goto tr9;
170
156
  }
171
157
  goto st0;
172
158
  tr8:
173
- #line 53 "ext/puma_http11/http11_parser.rl"
159
+ #line 39 "ext/puma_http11/http11_parser.rl"
174
160
  {
175
161
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
176
162
  }
177
163
  goto st5;
178
164
  tr31:
179
- #line 37 "ext/puma_http11/http11_parser.rl"
165
+ #line 23 "ext/puma_http11/http11_parser.rl"
180
166
  { MARK(mark, p); }
181
- #line 56 "ext/puma_http11/http11_parser.rl"
167
+ #line 42 "ext/puma_http11/http11_parser.rl"
182
168
  {
183
169
  parser->fragment(parser, PTR_TO(mark), LEN(mark, p));
184
170
  }
185
171
  goto st5;
186
172
  tr33:
187
- #line 56 "ext/puma_http11/http11_parser.rl"
173
+ #line 42 "ext/puma_http11/http11_parser.rl"
188
174
  {
189
175
  parser->fragment(parser, PTR_TO(mark), LEN(mark, p));
190
176
  }
191
177
  goto st5;
192
178
  tr37:
193
- #line 69 "ext/puma_http11/http11_parser.rl"
179
+ #line 55 "ext/puma_http11/http11_parser.rl"
194
180
  {
195
181
  parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
196
182
  }
197
- #line 53 "ext/puma_http11/http11_parser.rl"
183
+ #line 39 "ext/puma_http11/http11_parser.rl"
198
184
  {
199
185
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
200
186
  }
201
187
  goto st5;
202
188
  tr41:
203
- #line 60 "ext/puma_http11/http11_parser.rl"
189
+ #line 46 "ext/puma_http11/http11_parser.rl"
204
190
  { MARK(query_start, p); }
205
- #line 61 "ext/puma_http11/http11_parser.rl"
191
+ #line 47 "ext/puma_http11/http11_parser.rl"
206
192
  {
207
193
  parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
208
194
  }
209
- #line 53 "ext/puma_http11/http11_parser.rl"
195
+ #line 39 "ext/puma_http11/http11_parser.rl"
210
196
  {
211
197
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
212
198
  }
213
199
  goto st5;
214
200
  tr44:
215
- #line 61 "ext/puma_http11/http11_parser.rl"
201
+ #line 47 "ext/puma_http11/http11_parser.rl"
216
202
  {
217
203
  parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
218
204
  }
219
- #line 53 "ext/puma_http11/http11_parser.rl"
205
+ #line 39 "ext/puma_http11/http11_parser.rl"
220
206
  {
221
207
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
222
208
  }
@@ -225,19 +211,19 @@ st5:
225
211
  if ( ++p == pe )
226
212
  goto _test_eof5;
227
213
  case 5:
228
- #line 229 "ext/puma_http11/http11_parser.c"
214
+ #line 215 "ext/puma_http11/http11_parser.c"
229
215
  if ( (*p) == 72 )
230
216
  goto tr10;
231
217
  goto st0;
232
218
  tr10:
233
- #line 37 "ext/puma_http11/http11_parser.rl"
219
+ #line 23 "ext/puma_http11/http11_parser.rl"
234
220
  { MARK(mark, p); }
235
221
  goto st6;
236
222
  st6:
237
223
  if ( ++p == pe )
238
224
  goto _test_eof6;
239
225
  case 6:
240
- #line 241 "ext/puma_http11/http11_parser.c"
226
+ #line 227 "ext/puma_http11/http11_parser.c"
241
227
  if ( (*p) == 84 )
242
228
  goto st7;
243
229
  goto st0;
@@ -275,8 +261,6 @@ st11:
275
261
  case 11:
276
262
  if ( (*p) == 46 )
277
263
  goto st12;
278
- if ( 48 <= (*p) && (*p) <= 57 )
279
- goto st11;
280
264
  goto st0;
281
265
  st12:
282
266
  if ( ++p == pe )
@@ -291,25 +275,23 @@ st13:
291
275
  case 13:
292
276
  if ( (*p) == 13 )
293
277
  goto tr18;
294
- if ( 48 <= (*p) && (*p) <= 57 )
295
- goto st13;
296
278
  goto st0;
297
279
  tr18:
298
- #line 65 "ext/puma_http11/http11_parser.rl"
280
+ #line 51 "ext/puma_http11/http11_parser.rl"
299
281
  {
300
282
  parser->server_protocol(parser, PTR_TO(mark), LEN(mark, p));
301
283
  }
302
284
  goto st14;
303
285
  tr26:
304
- #line 46 "ext/puma_http11/http11_parser.rl"
286
+ #line 32 "ext/puma_http11/http11_parser.rl"
305
287
  { MARK(mark, p); }
306
- #line 47 "ext/puma_http11/http11_parser.rl"
288
+ #line 33 "ext/puma_http11/http11_parser.rl"
307
289
  {
308
290
  parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
309
291
  }
310
292
  goto st14;
311
293
  tr29:
312
- #line 47 "ext/puma_http11/http11_parser.rl"
294
+ #line 33 "ext/puma_http11/http11_parser.rl"
313
295
  {
314
296
  parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
315
297
  }
@@ -318,7 +300,7 @@ st14:
318
300
  if ( ++p == pe )
319
301
  goto _test_eof14;
320
302
  case 14:
321
- #line 322 "ext/puma_http11/http11_parser.c"
303
+ #line 304 "ext/puma_http11/http11_parser.c"
322
304
  if ( (*p) == 10 )
323
305
  goto st15;
324
306
  goto st0;
@@ -358,7 +340,7 @@ case 16:
358
340
  goto tr22;
359
341
  goto st0;
360
342
  tr22:
361
- #line 73 "ext/puma_http11/http11_parser.rl"
343
+ #line 59 "ext/puma_http11/http11_parser.rl"
362
344
  {
363
345
  parser->body_start = p - buffer + 1;
364
346
  parser->header_done(parser, p + 1, pe - p - 1);
@@ -369,23 +351,23 @@ st46:
369
351
  if ( ++p == pe )
370
352
  goto _test_eof46;
371
353
  case 46:
372
- #line 373 "ext/puma_http11/http11_parser.c"
354
+ #line 355 "ext/puma_http11/http11_parser.c"
373
355
  goto st0;
374
356
  tr21:
375
- #line 40 "ext/puma_http11/http11_parser.rl"
357
+ #line 26 "ext/puma_http11/http11_parser.rl"
376
358
  { MARK(field_start, p); }
377
- #line 41 "ext/puma_http11/http11_parser.rl"
378
- { snake_upcase_char((char *)p); }
359
+ #line 27 "ext/puma_http11/http11_parser.rl"
360
+ { /* the name is normalized into parser->buf by http_field */ }
379
361
  goto st17;
380
362
  tr23:
381
- #line 41 "ext/puma_http11/http11_parser.rl"
382
- { snake_upcase_char((char *)p); }
363
+ #line 27 "ext/puma_http11/http11_parser.rl"
364
+ { /* the name is normalized into parser->buf by http_field */ }
383
365
  goto st17;
384
366
  st17:
385
367
  if ( ++p == pe )
386
368
  goto _test_eof17;
387
369
  case 17:
388
- #line 389 "ext/puma_http11/http11_parser.c"
370
+ #line 371 "ext/puma_http11/http11_parser.c"
389
371
  switch( (*p) ) {
390
372
  case 33: goto tr23;
391
373
  case 58: goto tr24;
@@ -411,20 +393,20 @@ case 17:
411
393
  goto tr23;
412
394
  goto st0;
413
395
  tr24:
414
- #line 42 "ext/puma_http11/http11_parser.rl"
396
+ #line 28 "ext/puma_http11/http11_parser.rl"
415
397
  {
416
398
  parser->field_len = LEN(field_start, p);
417
399
  }
418
400
  goto st18;
419
401
  tr27:
420
- #line 46 "ext/puma_http11/http11_parser.rl"
402
+ #line 32 "ext/puma_http11/http11_parser.rl"
421
403
  { MARK(mark, p); }
422
404
  goto st18;
423
405
  st18:
424
406
  if ( ++p == pe )
425
407
  goto _test_eof18;
426
408
  case 18:
427
- #line 428 "ext/puma_http11/http11_parser.c"
409
+ #line 410 "ext/puma_http11/http11_parser.c"
428
410
  switch( (*p) ) {
429
411
  case 13: goto tr26;
430
412
  case 32: goto tr27;
@@ -437,14 +419,14 @@ case 18:
437
419
  goto st0;
438
420
  goto tr25;
439
421
  tr25:
440
- #line 46 "ext/puma_http11/http11_parser.rl"
422
+ #line 32 "ext/puma_http11/http11_parser.rl"
441
423
  { MARK(mark, p); }
442
424
  goto st19;
443
425
  st19:
444
426
  if ( ++p == pe )
445
427
  goto _test_eof19;
446
428
  case 19:
447
- #line 448 "ext/puma_http11/http11_parser.c"
429
+ #line 430 "ext/puma_http11/http11_parser.c"
448
430
  switch( (*p) ) {
449
431
  case 13: goto tr29;
450
432
  case 127: goto st0;
@@ -456,39 +438,39 @@ case 19:
456
438
  goto st0;
457
439
  goto st19;
458
440
  tr9:
459
- #line 53 "ext/puma_http11/http11_parser.rl"
441
+ #line 39 "ext/puma_http11/http11_parser.rl"
460
442
  {
461
443
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
462
444
  }
463
445
  goto st20;
464
446
  tr38:
465
- #line 69 "ext/puma_http11/http11_parser.rl"
447
+ #line 55 "ext/puma_http11/http11_parser.rl"
466
448
  {
467
449
  parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
468
450
  }
469
- #line 53 "ext/puma_http11/http11_parser.rl"
451
+ #line 39 "ext/puma_http11/http11_parser.rl"
470
452
  {
471
453
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
472
454
  }
473
455
  goto st20;
474
456
  tr42:
475
- #line 60 "ext/puma_http11/http11_parser.rl"
457
+ #line 46 "ext/puma_http11/http11_parser.rl"
476
458
  { MARK(query_start, p); }
477
- #line 61 "ext/puma_http11/http11_parser.rl"
459
+ #line 47 "ext/puma_http11/http11_parser.rl"
478
460
  {
479
461
  parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
480
462
  }
481
- #line 53 "ext/puma_http11/http11_parser.rl"
463
+ #line 39 "ext/puma_http11/http11_parser.rl"
482
464
  {
483
465
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
484
466
  }
485
467
  goto st20;
486
468
  tr45:
487
- #line 61 "ext/puma_http11/http11_parser.rl"
469
+ #line 47 "ext/puma_http11/http11_parser.rl"
488
470
  {
489
471
  parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
490
472
  }
491
- #line 53 "ext/puma_http11/http11_parser.rl"
473
+ #line 39 "ext/puma_http11/http11_parser.rl"
492
474
  {
493
475
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
494
476
  }
@@ -497,7 +479,7 @@ st20:
497
479
  if ( ++p == pe )
498
480
  goto _test_eof20;
499
481
  case 20:
500
- #line 501 "ext/puma_http11/http11_parser.c"
482
+ #line 483 "ext/puma_http11/http11_parser.c"
501
483
  switch( (*p) ) {
502
484
  case 32: goto tr31;
503
485
  case 60: goto st0;
@@ -511,14 +493,14 @@ case 20:
511
493
  goto st0;
512
494
  goto tr30;
513
495
  tr30:
514
- #line 37 "ext/puma_http11/http11_parser.rl"
496
+ #line 23 "ext/puma_http11/http11_parser.rl"
515
497
  { MARK(mark, p); }
516
498
  goto st21;
517
499
  st21:
518
500
  if ( ++p == pe )
519
501
  goto _test_eof21;
520
502
  case 21:
521
- #line 522 "ext/puma_http11/http11_parser.c"
503
+ #line 504 "ext/puma_http11/http11_parser.c"
522
504
  switch( (*p) ) {
523
505
  case 32: goto tr33;
524
506
  case 60: goto st0;
@@ -532,14 +514,14 @@ case 21:
532
514
  goto st0;
533
515
  goto st21;
534
516
  tr5:
535
- #line 37 "ext/puma_http11/http11_parser.rl"
517
+ #line 23 "ext/puma_http11/http11_parser.rl"
536
518
  { MARK(mark, p); }
537
519
  goto st22;
538
520
  st22:
539
521
  if ( ++p == pe )
540
522
  goto _test_eof22;
541
523
  case 22:
542
- #line 543 "ext/puma_http11/http11_parser.c"
524
+ #line 525 "ext/puma_http11/http11_parser.c"
543
525
  switch( (*p) ) {
544
526
  case 43: goto st22;
545
527
  case 58: goto st23;
@@ -557,14 +539,14 @@ case 22:
557
539
  goto st22;
558
540
  goto st0;
559
541
  tr7:
560
- #line 37 "ext/puma_http11/http11_parser.rl"
542
+ #line 23 "ext/puma_http11/http11_parser.rl"
561
543
  { MARK(mark, p); }
562
544
  goto st23;
563
545
  st23:
564
546
  if ( ++p == pe )
565
547
  goto _test_eof23;
566
548
  case 23:
567
- #line 568 "ext/puma_http11/http11_parser.c"
549
+ #line 550 "ext/puma_http11/http11_parser.c"
568
550
  switch( (*p) ) {
569
551
  case 32: goto tr8;
570
552
  case 34: goto st0;
@@ -577,14 +559,14 @@ case 23:
577
559
  goto st0;
578
560
  goto st23;
579
561
  tr6:
580
- #line 37 "ext/puma_http11/http11_parser.rl"
562
+ #line 23 "ext/puma_http11/http11_parser.rl"
581
563
  { MARK(mark, p); }
582
564
  goto st24;
583
565
  st24:
584
566
  if ( ++p == pe )
585
567
  goto _test_eof24;
586
568
  case 24:
587
- #line 588 "ext/puma_http11/http11_parser.c"
569
+ #line 570 "ext/puma_http11/http11_parser.c"
588
570
  switch( (*p) ) {
589
571
  case 32: goto tr37;
590
572
  case 34: goto st0;
@@ -602,7 +584,7 @@ case 24:
602
584
  goto st0;
603
585
  goto st24;
604
586
  tr39:
605
- #line 69 "ext/puma_http11/http11_parser.rl"
587
+ #line 55 "ext/puma_http11/http11_parser.rl"
606
588
  {
607
589
  parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
608
590
  }
@@ -611,7 +593,7 @@ st25:
611
593
  if ( ++p == pe )
612
594
  goto _test_eof25;
613
595
  case 25:
614
- #line 615 "ext/puma_http11/http11_parser.c"
596
+ #line 597 "ext/puma_http11/http11_parser.c"
615
597
  switch( (*p) ) {
616
598
  case 32: goto tr41;
617
599
  case 34: goto st0;
@@ -624,14 +606,14 @@ case 25:
624
606
  goto st0;
625
607
  goto tr40;
626
608
  tr40:
627
- #line 60 "ext/puma_http11/http11_parser.rl"
609
+ #line 46 "ext/puma_http11/http11_parser.rl"
628
610
  { MARK(query_start, p); }
629
611
  goto st26;
630
612
  st26:
631
613
  if ( ++p == pe )
632
614
  goto _test_eof26;
633
615
  case 26:
634
- #line 635 "ext/puma_http11/http11_parser.c"
616
+ #line 617 "ext/puma_http11/http11_parser.c"
635
617
  switch( (*p) ) {
636
618
  case 32: goto tr44;
637
619
  case 34: goto st0;
@@ -1025,7 +1007,7 @@ case 45:
1025
1007
  _out: {}
1026
1008
  }
1027
1009
 
1028
- #line 117 "ext/puma_http11/http11_parser.rl"
1010
+ #line 103 "ext/puma_http11/http11_parser.rl"
1029
1011
 
1030
1012
  if (!puma_parser_has_error(parser))
1031
1013
  parser->cs = cs;
@@ -7,15 +7,10 @@
7
7
  #ifndef http11_parser_h
8
8
  #define http11_parser_h
9
9
 
10
- #define RSTRING_NOT_MODIFIED 1
11
10
  #include "ruby.h"
12
11
 
13
12
  #include <sys/types.h>
14
13
 
15
- #if defined(_WIN32)
16
- #include <stddef.h>
17
- #endif
18
-
19
14
  #define BUFFER_LEN 1024
20
15
 
21
16
  struct puma_parser;
@@ -1,14 +1,11 @@
1
- #define RSTRING_NOT_MODIFIED 1
2
-
3
1
  #include <ruby.h>
4
- #include <ruby/version.h>
5
2
  #include <ruby/io.h>
6
3
 
7
- #ifdef HAVE_OPENSSL_BIO_H
8
-
9
4
  #include <openssl/bio.h>
10
5
  #include <openssl/ssl.h>
6
+ #ifndef HAVE_SSL_CTX_SET_DH_AUTO
11
7
  #include <openssl/dh.h>
8
+ #endif
12
9
  #include <openssl/err.h>
13
10
  #include <openssl/x509.h>
14
11
 
@@ -109,17 +106,17 @@ DH *get_dh2048(void) {
109
106
  static unsigned char dh2048_g[] = { 0x02 };
110
107
 
111
108
  DH *dh;
112
- #if !(OPENSSL_VERSION_NUMBER < 0x10100005L)
109
+ #if OPENSSL_VERSION_NUMBER >= 0x10100005L
113
110
  BIGNUM *p, *g;
114
111
  #endif
115
112
 
116
113
  dh = DH_new();
114
+ if (dh == NULL) return NULL;
117
115
 
118
116
  #if OPENSSL_VERSION_NUMBER < 0x10100005L
119
117
  dh->p = BN_bin2bn(dh2048_p, sizeof(dh2048_p), NULL);
120
118
  dh->g = BN_bin2bn(dh2048_g, sizeof(dh2048_g), NULL);
121
-
122
- if ((dh->p == NULL) || (dh->g == NULL)) {
119
+ if (dh->p == NULL || dh->g == NULL) {
123
120
  DH_free(dh);
124
121
  return NULL;
125
122
  }
@@ -218,7 +215,6 @@ sslctx_alloc(VALUE klass) {
218
215
 
219
216
  #ifdef HAVE_TLS_SERVER_METHOD
220
217
  ctx = SSL_CTX_new(TLS_method());
221
- // printf("\nctx using TLS_method security_level %d\n", SSL_CTX_get_security_level(ctx));
222
218
  #else
223
219
  ctx = SSL_CTX_new(SSLv23_method());
224
220
  #endif
@@ -234,7 +230,10 @@ VALUE
234
230
  sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
235
231
  SSL_CTX* ctx;
236
232
  int ssl_options, private_key_result;
237
- VALUE key, cert, ca, verify_mode, ssl_cipher_filter, ssl_ciphersuites, no_tlsv1, no_tlsv1_1,
233
+ #ifdef HAVE_SSL_CTX_SET_CIPHERSUITES
234
+ VALUE ssl_ciphersuites;
235
+ #endif
236
+ VALUE key, cert, ca, verify_mode, ssl_cipher_filter, no_tlsv1, no_tlsv1_1,
238
237
  verification_flags, session_id_bytes, cert_pem, key_pem, key_password_command, key_password;
239
238
  BIO *bio;
240
239
  X509 *x509 = NULL;
@@ -274,7 +273,9 @@ sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
274
273
 
275
274
  ssl_cipher_filter = rb_funcall(mini_ssl_ctx, rb_intern_const("ssl_cipher_filter"), 0);
276
275
 
276
+ #ifdef HAVE_SSL_CTX_SET_CIPHERSUITES
277
277
  ssl_ciphersuites = rb_funcall(mini_ssl_ctx, rb_intern_const("ssl_ciphersuites"), 0);
278
+ #endif
278
279
 
279
280
  no_tlsv1 = rb_funcall(mini_ssl_ctx, rb_intern_const("no_tlsv1"), 0);
280
281
 
@@ -420,15 +421,12 @@ sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
420
421
  }
421
422
 
422
423
  SSL_CTX_set_min_proto_version(ctx, min);
423
-
424
424
  #else
425
- /* As of 1.0.2f, SSL_OP_SINGLE_DH_USE key use is always on */
426
425
  ssl_options |= SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_SINGLE_DH_USE;
427
-
428
426
  if (RTEST(no_tlsv1)) {
429
427
  ssl_options |= SSL_OP_NO_TLSv1;
430
428
  }
431
- if(RTEST(no_tlsv1_1)) {
429
+ if (RTEST(no_tlsv1_1)) {
432
430
  ssl_options |= SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1;
433
431
  }
434
432
  #endif
@@ -464,7 +462,7 @@ sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
464
462
  SSL_CTX_set_cipher_list(ctx, "HIGH:!aNULL@STRENGTH");
465
463
  }
466
464
 
467
- #if HAVE_SSL_CTX_SET_CIPHERSUITES
465
+ #ifdef HAVE_SSL_CTX_SET_CIPHERSUITES
468
466
  // Only override OpenSSL default ciphersuites if config option is supplied.
469
467
  if (!NIL_P(ssl_ciphersuites)) {
470
468
  StringValue(ssl_ciphersuites);
@@ -473,7 +471,6 @@ sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
473
471
  #endif
474
472
 
475
473
  #if OPENSSL_VERSION_NUMBER < 0x10002000L
476
- // Remove this case if OpenSSL 1.0.1 (now EOL) support is no longer needed.
477
474
  ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
478
475
  if (ecdh) {
479
476
  SSL_CTX_set_tmp_ecdh(ctx, ecdh);
@@ -483,9 +480,7 @@ sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
483
480
  SSL_CTX_set_ecdh_auto(ctx, 1);
484
481
  #endif
485
482
 
486
- if (NIL_P(verify_mode)) {
487
- /* SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); */
488
- } else {
483
+ if (!NIL_P(verify_mode)) {
489
484
  SSL_CTX_set_verify(ctx, NUM2INT(verify_mode), engine_verify_callback);
490
485
  }
491
486
 
@@ -498,8 +493,6 @@ sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
498
493
  (unsigned char *) RSTRING_PTR(session_id_bytes),
499
494
  SSL_MAX_SSL_SESSION_ID_LENGTH);
500
495
 
501
- // printf("\ninitialize end security_level %d\n", SSL_CTX_get_security_level(ctx));
502
-
503
496
  #ifdef HAVE_SSL_CTX_SET_DH_AUTO
504
497
  // https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_dh_auto.html
505
498
  SSL_CTX_set_dh_auto(ctx, 1);
@@ -776,10 +769,12 @@ void Init_mini_ssl(VALUE puma) {
776
769
  puma = rb_define_module("Puma");
777
770
  #endif
778
771
 
772
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
779
773
  SSL_library_init();
780
774
  OpenSSL_add_ssl_algorithms();
781
775
  SSL_load_error_strings();
782
776
  ERR_load_crypto_strings();
777
+ #endif
783
778
 
784
779
  mod = rb_define_module_under(puma, "MiniSSL");
785
780
 
@@ -797,34 +792,13 @@ void Init_mini_ssl(VALUE puma) {
797
792
  /* Version of OpenSSL that Puma was compiled with */
798
793
  rb_define_const(mod, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT));
799
794
 
800
- #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
801
795
  /* Version of OpenSSL that Puma loaded with */
796
+ #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L
802
797
  rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(OpenSSL_version(OPENSSL_VERSION)));
803
798
  #else
804
799
  rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION)));
805
800
  #endif
806
801
 
807
- #if defined(OPENSSL_NO_SSL3) || defined(OPENSSL_NO_SSL3_METHOD)
808
- /* True if SSL3 is not available */
809
- rb_define_const(mod, "OPENSSL_NO_SSL3", Qtrue);
810
- #else
811
- rb_define_const(mod, "OPENSSL_NO_SSL3", Qfalse);
812
- #endif
813
-
814
- #if defined(OPENSSL_NO_TLS1) || defined(OPENSSL_NO_TLS1_METHOD)
815
- /* True if TLS1 is not available */
816
- rb_define_const(mod, "OPENSSL_NO_TLS1", Qtrue);
817
- #else
818
- rb_define_const(mod, "OPENSSL_NO_TLS1", Qfalse);
819
- #endif
820
-
821
- #if defined(OPENSSL_NO_TLS1_1) || defined(OPENSSL_NO_TLS1_1_METHOD)
822
- /* True if TLS1_1 is not available */
823
- rb_define_const(mod, "OPENSSL_NO_TLS1_1", Qtrue);
824
- #else
825
- rb_define_const(mod, "OPENSSL_NO_TLS1_1", Qfalse);
826
- #endif
827
-
828
802
  rb_define_singleton_method(mod, "check", noop, 0);
829
803
 
830
804
  eError = rb_define_class_under(mod, "SSLError", rb_eStandardError);
@@ -850,21 +824,3 @@ void Init_mini_ssl(VALUE puma) {
850
824
 
851
825
  rb_define_method(eng, "ssl_vers_st", engine_ssl_vers_st, 0);
852
826
  }
853
-
854
- #else
855
-
856
- NORETURN(VALUE raise_error(VALUE self));
857
-
858
- VALUE raise_error(VALUE self) {
859
- rb_raise(rb_eStandardError, "SSL not available in this build");
860
- }
861
-
862
- void Init_mini_ssl(VALUE puma) {
863
- VALUE mod;
864
-
865
- mod = rb_define_module_under(puma, "MiniSSL");
866
- rb_define_class_under(mod, "SSLError", rb_eStandardError);
867
-
868
- rb_define_singleton_method(mod, "check", raise_error, 0);
869
- }
870
- #endif