puma 3.11.4 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +1717 -432
  3. data/LICENSE +23 -20
  4. data/README.md +190 -64
  5. data/bin/puma-wild +3 -9
  6. data/docs/architecture.md +59 -21
  7. data/docs/compile_options.md +55 -0
  8. data/docs/deployment.md +69 -58
  9. data/docs/fork_worker.md +31 -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/jungle/README.md +9 -0
  14. data/{tools → docs}/jungle/rc.d/README.md +1 -1
  15. data/{tools → docs}/jungle/rc.d/puma +2 -2
  16. data/{tools → docs}/jungle/rc.d/puma.conf +0 -0
  17. data/docs/kubernetes.md +66 -0
  18. data/docs/nginx.md +2 -2
  19. data/docs/plugins.md +22 -12
  20. data/docs/rails_dev_mode.md +28 -0
  21. data/docs/restart.md +47 -22
  22. data/docs/signals.md +13 -11
  23. data/docs/stats.md +142 -0
  24. data/docs/systemd.md +95 -120
  25. data/docs/testing_benchmarks_local_files.md +150 -0
  26. data/docs/testing_test_rackup_ci_files.md +36 -0
  27. data/ext/puma_http11/PumaHttp11Service.java +2 -2
  28. data/ext/puma_http11/ext_help.h +1 -1
  29. data/ext/puma_http11/extconf.rb +61 -3
  30. data/ext/puma_http11/http11_parser.c +106 -118
  31. data/ext/puma_http11/http11_parser.h +2 -2
  32. data/ext/puma_http11/http11_parser.java.rl +22 -38
  33. data/ext/puma_http11/http11_parser.rl +6 -4
  34. data/ext/puma_http11/http11_parser_common.rl +6 -6
  35. data/ext/puma_http11/mini_ssl.c +376 -93
  36. data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
  37. data/ext/puma_http11/org/jruby/puma/Http11.java +108 -116
  38. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +84 -99
  39. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +250 -88
  40. data/ext/puma_http11/puma_http11.c +49 -57
  41. data/lib/puma/app/status.rb +71 -49
  42. data/lib/puma/binder.rb +243 -148
  43. data/lib/puma/cli.rb +50 -36
  44. data/lib/puma/client.rb +373 -233
  45. data/lib/puma/cluster/worker.rb +175 -0
  46. data/lib/puma/cluster/worker_handle.rb +97 -0
  47. data/lib/puma/cluster.rb +268 -235
  48. data/lib/puma/commonlogger.rb +4 -2
  49. data/lib/puma/configuration.rb +116 -88
  50. data/lib/puma/const.rb +49 -30
  51. data/lib/puma/control_cli.rb +123 -76
  52. data/lib/puma/detect.rb +33 -2
  53. data/lib/puma/dsl.rb +685 -135
  54. data/lib/puma/error_logger.rb +112 -0
  55. data/lib/puma/events.rb +17 -111
  56. data/lib/puma/io_buffer.rb +44 -5
  57. data/lib/puma/jruby_restart.rb +4 -59
  58. data/lib/puma/json_serialization.rb +96 -0
  59. data/lib/puma/launcher/bundle_pruner.rb +104 -0
  60. data/lib/puma/launcher.rb +196 -130
  61. data/lib/puma/log_writer.rb +137 -0
  62. data/lib/puma/minissl/context_builder.rb +92 -0
  63. data/lib/puma/minissl.rb +249 -69
  64. data/lib/puma/null_io.rb +20 -1
  65. data/lib/puma/plugin/tmp_restart.rb +3 -1
  66. data/lib/puma/plugin.rb +9 -13
  67. data/lib/puma/rack/builder.rb +8 -9
  68. data/lib/puma/rack/urlmap.rb +2 -0
  69. data/lib/puma/rack_default.rb +3 -1
  70. data/lib/puma/reactor.rb +90 -187
  71. data/lib/puma/request.rb +644 -0
  72. data/lib/puma/runner.rb +94 -71
  73. data/lib/puma/server.rb +337 -715
  74. data/lib/puma/single.rb +27 -72
  75. data/lib/puma/state_file.rb +46 -7
  76. data/lib/puma/systemd.rb +47 -0
  77. data/lib/puma/thread_pool.rb +184 -93
  78. data/lib/puma/util.rb +23 -10
  79. data/lib/puma.rb +60 -3
  80. data/lib/rack/handler/puma.rb +17 -15
  81. data/tools/Dockerfile +16 -0
  82. data/tools/trickletest.rb +0 -1
  83. metadata +53 -33
  84. data/ext/puma_http11/io_buffer.c +0 -155
  85. data/lib/puma/accept_nonblock.rb +0 -23
  86. data/lib/puma/compat.rb +0 -14
  87. data/lib/puma/convenient.rb +0 -23
  88. data/lib/puma/daemon_ext.rb +0 -31
  89. data/lib/puma/delegation.rb +0 -11
  90. data/lib/puma/java_io_buffer.rb +0 -45
  91. data/lib/puma/rack/backports/uri/common_193.rb +0 -33
  92. data/lib/puma/tcp_logger.rb +0 -39
  93. data/tools/jungle/README.md +0 -19
  94. data/tools/jungle/init.d/README.md +0 -61
  95. data/tools/jungle/init.d/puma +0 -421
  96. data/tools/jungle/init.d/run-puma +0 -18
  97. data/tools/jungle/upstart/README.md +0 -61
  98. data/tools/jungle/upstart/puma-manager.conf +0 -31
  99. data/tools/jungle/upstart/puma.conf +0 -69
@@ -2,13 +2,71 @@ require 'mkmf'
2
2
 
3
3
  dir_config("puma_http11")
4
4
 
5
- unless ENV["DISABLE_SSL"]
6
- dir_config("openssl")
5
+ if $mingw
6
+ append_cflags '-fstack-protector-strong -D_FORTIFY_SOURCE=2'
7
+ append_ldflags '-fstack-protector-strong -l:libssp.a'
8
+ have_library 'ssp'
9
+ end
10
+
11
+ unless ENV["PUMA_DISABLE_SSL"]
12
+ # don't use pkg_config('openssl') if '--with-openssl-dir' is used
13
+ has_openssl_dir = dir_config('openssl').any?
14
+ found_pkg_config = !has_openssl_dir && pkg_config('openssl')
7
15
 
8
- if %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} and
16
+ found_ssl = if !$mingw && found_pkg_config
17
+ puts 'using OpenSSL pkgconfig (openssl.pc)'
18
+ true
19
+ elsif have_library('libcrypto', 'BIO_read') && have_library('libssl', 'SSL_CTX_new')
20
+ true
21
+ elsif %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} &&
9
22
  %w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
23
+ true
24
+ else
25
+ puts '** Puma will be compiled without SSL support'
26
+ false
27
+ end
10
28
 
29
+ if found_ssl
11
30
  have_header "openssl/bio.h"
31
+
32
+ # below is yes for 1.0.2 & later
33
+ have_func "DTLS_method" , "openssl/ssl.h"
34
+ have_func "SSL_CTX_set_session_cache_mode(NULL, 0)", "openssl/ssl.h"
35
+
36
+ # below are yes for 1.1.0 & later
37
+ have_func "TLS_server_method" , "openssl/ssl.h"
38
+ have_func "SSL_CTX_set_min_proto_version(NULL, 0)" , "openssl/ssl.h"
39
+
40
+ have_func "X509_STORE_up_ref"
41
+ have_func "SSL_CTX_set_ecdh_auto(NULL, 0)" , "openssl/ssl.h"
42
+
43
+ # below exists in 1.1.0 and later, but isn't documented until 3.0.0
44
+ have_func "SSL_CTX_set_dh_auto(NULL, 0)" , "openssl/ssl.h"
45
+
46
+ # below is yes for 3.0.0 & later
47
+ have_func "SSL_get1_peer_certificate" , "openssl/ssl.h"
48
+
49
+ # Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated in 3.0
50
+ if Random.respond_to?(:bytes)
51
+ $defs.push "-DHAVE_RANDOM_BYTES"
52
+ puts "checking for Random.bytes... yes"
53
+ else
54
+ puts "checking for Random.bytes... no"
55
+ end
56
+ end
57
+ end
58
+
59
+ if ENV["PUMA_MAKE_WARNINGS_INTO_ERRORS"]
60
+ # Make all warnings into errors
61
+ # Except `implicit-fallthrough` since most failures comes from ragel state machine generated code
62
+ if respond_to?(:append_cflags, true) # Ruby 2.5 and later
63
+ append_cflags(config_string('WERRORFLAG') || '-Werror')
64
+ append_cflags '-Wno-implicit-fallthrough'
65
+ else
66
+ # flag may not exist on some platforms, -Werror may not be defined on some platforms, but
67
+ # works with all in current CI
68
+ $CFLAGS << " #{config_string('WERRORFLAG') || '-Werror'}"
69
+ $CFLAGS << ' -Wno-implicit-fallthrough'
12
70
  end
13
71
  end
14
72
 
@@ -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 79 "ext/puma_http11/http11_parser.rl"
36
+ #line 81 "ext/puma_http11/http11_parser.rl"
35
37
 
36
38
 
37
39
  /** Data **/
38
40
 
39
- #line 40 "ext/puma_http11/http11_parser.c"
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 = 47;
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 87 "ext/puma_http11/http11_parser.rl"
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 35 "ext/puma_http11/http11_parser.rl"
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 st28;
121
- case 95: goto st28;
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 st28;
125
+ goto st27;
126
126
  } else if ( (*p) > 57 ) {
127
127
  if ( 65 <= (*p) && (*p) <= 90 )
128
- goto st28;
128
+ goto st27;
129
129
  } else
130
- goto st28;
130
+ goto st27;
131
131
  goto st0;
132
132
  tr2:
133
- #line 48 "ext/puma_http11/http11_parser.rl"
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 35 "ext/puma_http11/http11_parser.rl"
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 51 "ext/puma_http11/http11_parser.rl"
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 35 "ext/puma_http11/http11_parser.rl"
179
+ #line 37 "ext/puma_http11/http11_parser.rl"
180
180
  { MARK(mark, p); }
181
- #line 54 "ext/puma_http11/http11_parser.rl"
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 54 "ext/puma_http11/http11_parser.rl"
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 67 "ext/puma_http11/http11_parser.rl"
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 51 "ext/puma_http11/http11_parser.rl"
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
- tr44:
203
- #line 58 "ext/puma_http11/http11_parser.rl"
202
+ tr41:
203
+ #line 60 "ext/puma_http11/http11_parser.rl"
204
204
  { MARK(query_start, p); }
205
- #line 59 "ext/puma_http11/http11_parser.rl"
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 51 "ext/puma_http11/http11_parser.rl"
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
- tr47:
215
- #line 59 "ext/puma_http11/http11_parser.rl"
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 51 "ext/puma_http11/http11_parser.rl"
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 35 "ext/puma_http11/http11_parser.rl"
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 63 "ext/puma_http11/http11_parser.rl"
298
+ #line 65 "ext/puma_http11/http11_parser.rl"
299
299
  {
300
- parser->http_version(parser, PTR_TO(mark), LEN(mark, p));
300
+ parser->server_protocol(parser, PTR_TO(mark), LEN(mark, p));
301
301
  }
302
302
  goto st14;
303
303
  tr26:
304
- #line 44 "ext/puma_http11/http11_parser.rl"
304
+ #line 46 "ext/puma_http11/http11_parser.rl"
305
305
  { MARK(mark, p); }
306
- #line 45 "ext/puma_http11/http11_parser.rl"
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 45 "ext/puma_http11/http11_parser.rl"
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 71 "ext/puma_http11/http11_parser.rl"
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 = 47; goto _out;}
365
+ {p++; cs = 46; goto _out;}
366
366
  }
367
- goto st47;
368
- st47:
367
+ goto st46;
368
+ st46:
369
369
  if ( ++p == pe )
370
- goto _test_eof47;
371
- case 47:
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 38 "ext/puma_http11/http11_parser.rl"
375
+ #line 40 "ext/puma_http11/http11_parser.rl"
376
376
  { MARK(field_start, p); }
377
- #line 39 "ext/puma_http11/http11_parser.rl"
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 39 "ext/puma_http11/http11_parser.rl"
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 40 "ext/puma_http11/http11_parser.rl"
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 44 "ext/puma_http11/http11_parser.rl"
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 44 "ext/puma_http11/http11_parser.rl"
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 "ext/puma_http11/http11_parser.c"
442
- if ( (*p) == 13 )
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 51 "ext/puma_http11/http11_parser.rl"
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 67 "ext/puma_http11/http11_parser.rl"
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 51 "ext/puma_http11/http11_parser.rl"
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
- tr45:
462
- #line 58 "ext/puma_http11/http11_parser.rl"
474
+ tr42:
475
+ #line 60 "ext/puma_http11/http11_parser.rl"
463
476
  { MARK(query_start, p); }
464
- #line 59 "ext/puma_http11/http11_parser.rl"
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 51 "ext/puma_http11/http11_parser.rl"
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
- tr48:
474
- #line 59 "ext/puma_http11/http11_parser.rl"
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 51 "ext/puma_http11/http11_parser.rl"
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 488 "ext/puma_http11/http11_parser.c"
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 35 "ext/puma_http11/http11_parser.rl"
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 509 "ext/puma_http11/http11_parser.c"
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 35 "ext/puma_http11/http11_parser.rl"
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 530 "ext/puma_http11/http11_parser.c"
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 35 "ext/puma_http11/http11_parser.rl"
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 555 "ext/puma_http11/http11_parser.c"
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 35 "ext/puma_http11/http11_parser.rl"
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 575 "ext/puma_http11/http11_parser.c"
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 tr40;
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 67 "ext/puma_http11/http11_parser.rl"
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 599 "ext/puma_http11/http11_parser.c"
610
+ #line 611 "ext/puma_http11/http11_parser.c"
599
611
  switch( (*p) ) {
600
- case 32: goto tr8;
612
+ case 32: goto tr41;
601
613
  case 34: goto st0;
602
- case 35: goto tr9;
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 st25;
621
+ goto tr40;
611
622
  tr40:
612
- #line 67 "ext/puma_http11/http11_parser.rl"
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 622 "ext/puma_http11/http11_parser.c"
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 tr43;
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 tr47;
644
- case 34: goto st0;
645
- case 35: goto tr48;
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 ( 0 <= (*p) && (*p) <= 31 )
651
- goto st0;
652
- goto st27;
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
- _test_eof47: cs = 47; goto _test_eof;
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 115 "ext/puma_http11/http11_parser.rl"
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 http_version;
49
+ element_cb server_protocol;
50
50
  element_cb header_done;
51
51
 
52
52
  char buf[BUFFER_LEN];