puma 3.12.6 → 6.2.2

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 (100) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +1775 -451
  3. data/LICENSE +23 -20
  4. data/README.md +193 -65
  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 +94 -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 +103 -117
  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 +3 -3
  34. data/ext/puma_http11/http11_parser_common.rl +6 -6
  35. data/ext/puma_http11/mini_ssl.c +361 -99
  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 +248 -92
  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 +242 -150
  43. data/lib/puma/cli.rb +38 -34
  44. data/lib/puma/client.rb +387 -244
  45. data/lib/puma/cluster/worker.rb +180 -0
  46. data/lib/puma/cluster/worker_handle.rb +97 -0
  47. data/lib/puma/cluster.rb +261 -243
  48. data/lib/puma/commonlogger.rb +21 -14
  49. data/lib/puma/configuration.rb +116 -88
  50. data/lib/puma/const.rb +101 -100
  51. data/lib/puma/control_cli.rb +115 -70
  52. data/lib/puma/detect.rb +33 -2
  53. data/lib/puma/dsl.rb +731 -134
  54. data/lib/puma/error_logger.rb +113 -0
  55. data/lib/puma/events.rb +16 -112
  56. data/lib/puma/io_buffer.rb +42 -5
  57. data/lib/puma/jruby_restart.rb +2 -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 +184 -133
  61. data/lib/puma/log_writer.rb +147 -0
  62. data/lib/puma/minissl/context_builder.rb +92 -0
  63. data/lib/puma/minissl.rb +246 -70
  64. data/lib/puma/null_io.rb +18 -1
  65. data/lib/puma/plugin/systemd.rb +90 -0
  66. data/lib/puma/plugin/tmp_restart.rb +3 -1
  67. data/lib/puma/plugin.rb +7 -13
  68. data/lib/puma/rack/builder.rb +7 -9
  69. data/lib/puma/rack/urlmap.rb +2 -0
  70. data/lib/puma/rack_default.rb +21 -4
  71. data/lib/puma/reactor.rb +85 -316
  72. data/lib/puma/request.rb +665 -0
  73. data/lib/puma/runner.rb +94 -69
  74. data/lib/puma/sd_notify.rb +149 -0
  75. data/lib/puma/server.rb +314 -771
  76. data/lib/puma/single.rb +20 -74
  77. data/lib/puma/state_file.rb +45 -8
  78. data/lib/puma/thread_pool.rb +142 -92
  79. data/lib/puma/util.rb +22 -10
  80. data/lib/puma.rb +60 -5
  81. data/lib/rack/handler/puma.rb +113 -91
  82. data/tools/Dockerfile +16 -0
  83. data/tools/trickletest.rb +0 -1
  84. metadata +54 -32
  85. data/ext/puma_http11/io_buffer.c +0 -155
  86. data/lib/puma/accept_nonblock.rb +0 -23
  87. data/lib/puma/compat.rb +0 -14
  88. data/lib/puma/convenient.rb +0 -25
  89. data/lib/puma/daemon_ext.rb +0 -33
  90. data/lib/puma/delegation.rb +0 -13
  91. data/lib/puma/java_io_buffer.rb +0 -47
  92. data/lib/puma/rack/backports/uri/common_193.rb +0 -33
  93. data/lib/puma/tcp_logger.rb +0 -41
  94. data/tools/jungle/README.md +0 -19
  95. data/tools/jungle/init.d/README.md +0 -61
  96. data/tools/jungle/init.d/puma +0 -421
  97. data/tools/jungle/init.d/run-puma +0 -18
  98. data/tools/jungle/upstart/README.md +0 -61
  99. data/tools/jungle/upstart/puma-manager.conf +0 -31
  100. data/tools/jungle/upstart/puma.conf +0 -69
@@ -11,7 +11,6 @@ import org.jruby.RubyString;
11
11
  import org.jruby.anno.JRubyMethod;
12
12
 
13
13
  import org.jruby.runtime.ObjectAllocator;
14
- import org.jruby.runtime.ThreadContext;
15
14
  import org.jruby.runtime.builtin.IRubyObject;
16
15
 
17
16
  import org.jruby.exceptions.RaiseException;
@@ -20,6 +19,7 @@ import org.jruby.util.ByteList;
20
19
 
21
20
  /**
22
21
  * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
22
+ * @author <a href="mailto:headius@headius.com">Charles Oliver Nutter</a>
23
23
  */
24
24
  public class Http11 extends RubyObject {
25
25
  public final static int MAX_FIELD_NAME_LENGTH = 256;
@@ -30,13 +30,23 @@ public class Http11 extends RubyObject {
30
30
  public final static String MAX_REQUEST_URI_LENGTH_ERR = "HTTP element REQUEST_URI is longer than the 12288 allowed length.";
31
31
  public final static int MAX_FRAGMENT_LENGTH = 1024;
32
32
  public final static String MAX_FRAGMENT_LENGTH_ERR = "HTTP element REQUEST_PATH is longer than the 1024 allowed length.";
33
- public final static int MAX_REQUEST_PATH_LENGTH = 2048;
34
- public final static String MAX_REQUEST_PATH_LENGTH_ERR = "HTTP element REQUEST_PATH is longer than the 2048 allowed length.";
33
+ public final static int MAX_REQUEST_PATH_LENGTH = 8192;
34
+ public final static String MAX_REQUEST_PATH_LENGTH_ERR = "HTTP element REQUEST_PATH is longer than the 8192 allowed length.";
35
35
  public final static int MAX_QUERY_STRING_LENGTH = 1024 * 10;
36
36
  public final static String MAX_QUERY_STRING_LENGTH_ERR = "HTTP element QUERY_STRING is longer than the 10240 allowed length.";
37
37
  public final static int MAX_HEADER_LENGTH = 1024 * (80 + 32);
38
38
  public final static String MAX_HEADER_LENGTH_ERR = "HTTP element HEADER is longer than the 114688 allowed length.";
39
39
 
40
+ public static final ByteList CONTENT_TYPE_BYTELIST = new ByteList(ByteList.plain("CONTENT_TYPE"));
41
+ public static final ByteList CONTENT_LENGTH_BYTELIST = new ByteList(ByteList.plain("CONTENT_LENGTH"));
42
+ public static final ByteList HTTP_PREFIX_BYTELIST = new ByteList(ByteList.plain("HTTP_"));
43
+ public static final ByteList COMMA_SPACE_BYTELIST = new ByteList(ByteList.plain(", "));
44
+ public static final ByteList REQUEST_METHOD_BYTELIST = new ByteList(ByteList.plain("REQUEST_METHOD"));
45
+ public static final ByteList REQUEST_URI_BYTELIST = new ByteList(ByteList.plain("REQUEST_URI"));
46
+ public static final ByteList FRAGMENT_BYTELIST = new ByteList(ByteList.plain("FRAGMENT"));
47
+ public static final ByteList REQUEST_PATH_BYTELIST = new ByteList(ByteList.plain("REQUEST_PATH"));
48
+ public static final ByteList QUERY_STRING_BYTELIST = new ByteList(ByteList.plain("QUERY_STRING"));
49
+ public static final ByteList SERVER_PROTOCOL_BYTELIST = new ByteList(ByteList.plain("SERVER_PROTOCOL"));
40
50
 
41
51
  private static ObjectAllocator ALLOCATOR = new ObjectAllocator() {
42
52
  public IRubyObject allocate(Ruby runtime, RubyClass klass) {
@@ -53,127 +63,104 @@ public class Http11 extends RubyObject {
53
63
  }
54
64
 
55
65
  private Ruby runtime;
56
- private RubyClass eHttpParserError;
57
66
  private Http11Parser hp;
58
67
  private RubyString body;
59
68
 
60
69
  public Http11(Ruby runtime, RubyClass clazz) {
61
70
  super(runtime,clazz);
62
71
  this.runtime = runtime;
63
- this.eHttpParserError = (RubyClass)runtime.getModule("Puma").getConstant("HttpParserError");
64
72
  this.hp = new Http11Parser();
65
- this.hp.parser.http_field = http_field;
66
- this.hp.parser.request_method = request_method;
67
- this.hp.parser.request_uri = request_uri;
68
- this.hp.parser.fragment = fragment;
69
- this.hp.parser.request_path = request_path;
70
- this.hp.parser.query_string = query_string;
71
- this.hp.parser.http_version = http_version;
72
- this.hp.parser.header_done = header_done;
73
73
  this.hp.parser.init();
74
74
  }
75
75
 
76
- public void validateMaxLength(int len, int max, String msg) {
76
+ public static void validateMaxLength(Ruby runtime, int len, int max, String msg) {
77
77
  if(len>max) {
78
- throw new RaiseException(runtime, eHttpParserError, msg, true);
78
+ throw newHTTPParserError(runtime, msg);
79
79
  }
80
80
  }
81
81
 
82
- private Http11Parser.FieldCB http_field = new Http11Parser.FieldCB() {
83
- public void call(Object data, int field, int flen, int value, int vlen) {
84
- RubyHash req = (RubyHash)data;
85
- RubyString f;
86
- IRubyObject v;
87
- validateMaxLength(flen, MAX_FIELD_NAME_LENGTH, MAX_FIELD_NAME_LENGTH_ERR);
88
- validateMaxLength(vlen, MAX_FIELD_VALUE_LENGTH, MAX_FIELD_VALUE_LENGTH_ERR);
89
-
90
- ByteList b = new ByteList(Http11.this.hp.parser.buffer,field,flen);
91
- for(int i = 0,j = b.length();i<j;i++) {
92
- if((b.get(i) & 0xFF) == '-') {
93
- b.set(i, (byte)'_');
94
- } else {
95
- b.set(i, (byte)Character.toUpperCase((char)b.get(i)));
96
- }
97
- }
98
-
99
- String as = b.toString();
100
-
101
- if(as.equals("CONTENT_LENGTH") || as.equals("CONTENT_TYPE")) {
102
- f = RubyString.newString(runtime, b);
103
- } else {
104
- f = RubyString.newString(runtime, "HTTP_");
105
- f.cat(b);
106
- }
107
-
108
- b = new ByteList(Http11.this.hp.parser.buffer, value, vlen);
109
- v = req.op_aref(req.getRuntime().getCurrentContext(), f);
110
- if (v.isNil()) {
111
- req.op_aset(req.getRuntime().getCurrentContext(), f, RubyString.newString(runtime, b));
112
- } else {
113
- RubyString vs = v.convertToString();
114
- vs.cat(RubyString.newString(runtime, ", "));
115
- vs.cat(b);
116
- }
117
- }
118
- };
82
+ private static RaiseException newHTTPParserError(Ruby runtime, String msg) {
83
+ return runtime.newRaiseException(getHTTPParserError(runtime), msg);
84
+ }
119
85
 
120
- private Http11Parser.ElementCB request_method = new Http11Parser.ElementCB() {
121
- public void call(Object data, int at, int length) {
122
- RubyHash req = (RubyHash)data;
123
- RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
124
- req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("REQUEST_METHOD"),val);
125
- }
126
- };
127
-
128
- private Http11Parser.ElementCB request_uri = new Http11Parser.ElementCB() {
129
- public void call(Object data, int at, int length) {
130
- RubyHash req = (RubyHash)data;
131
- validateMaxLength(length, MAX_REQUEST_URI_LENGTH, MAX_REQUEST_URI_LENGTH_ERR);
132
- RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
133
- req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("REQUEST_URI"),val);
134
- }
135
- };
136
-
137
- private Http11Parser.ElementCB fragment = new Http11Parser.ElementCB() {
138
- public void call(Object data, int at, int length) {
139
- RubyHash req = (RubyHash)data;
140
- validateMaxLength(length, MAX_FRAGMENT_LENGTH, MAX_FRAGMENT_LENGTH_ERR);
141
- RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
142
- req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("FRAGMENT"),val);
143
- }
144
- };
145
-
146
- private Http11Parser.ElementCB request_path = new Http11Parser.ElementCB() {
147
- public void call(Object data, int at, int length) {
148
- RubyHash req = (RubyHash)data;
149
- validateMaxLength(length, MAX_REQUEST_PATH_LENGTH, MAX_REQUEST_PATH_LENGTH_ERR);
150
- RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
151
- req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("REQUEST_PATH"),val);
152
- }
153
- };
154
-
155
- private Http11Parser.ElementCB query_string = new Http11Parser.ElementCB() {
156
- public void call(Object data, int at, int length) {
157
- RubyHash req = (RubyHash)data;
158
- validateMaxLength(length, MAX_QUERY_STRING_LENGTH, MAX_QUERY_STRING_LENGTH_ERR);
159
- RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
160
- req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("QUERY_STRING"),val);
161
- }
162
- };
86
+ private static RubyClass getHTTPParserError(Ruby runtime) {
87
+ // Cheaper to look this up lazily than cache eagerly and consume a field, since it's rarely encountered
88
+ return (RubyClass)runtime.getModule("Puma").getConstant("HttpParserError");
89
+ }
163
90
 
164
- private Http11Parser.ElementCB http_version = new Http11Parser.ElementCB() {
165
- public void call(Object data, int at, int length) {
166
- RubyHash req = (RubyHash)data;
167
- RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
168
- req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("HTTP_VERSION"),val);
91
+ public static void http_field(Ruby runtime, RubyHash req, ByteList buffer, int field, int flen, int value, int vlen) {
92
+ RubyString f;
93
+ IRubyObject v;
94
+ validateMaxLength(runtime, flen, MAX_FIELD_NAME_LENGTH, MAX_FIELD_NAME_LENGTH_ERR);
95
+ validateMaxLength(runtime, vlen, MAX_FIELD_VALUE_LENGTH, MAX_FIELD_VALUE_LENGTH_ERR);
96
+
97
+ ByteList b = new ByteList(buffer,field,flen);
98
+ for(int i = 0,j = b.length();i<j;i++) {
99
+ int bite = b.get(i) & 0xFF;
100
+ if(bite == '-') {
101
+ b.set(i, (byte)'_');
102
+ } else {
103
+ b.set(i, (byte)Character.toUpperCase(bite));
169
104
  }
170
- };
105
+ }
171
106
 
172
- private Http11Parser.ElementCB header_done = new Http11Parser.ElementCB() {
173
- public void call(Object data, int at, int length) {
174
- body = RubyString.newString(runtime, new ByteList(hp.parser.buffer, at, length));
175
- }
176
- };
107
+ while (vlen > 0 && Character.isWhitespace(buffer.get(value + vlen - 1))) vlen--;
108
+
109
+ if (b.equals(CONTENT_LENGTH_BYTELIST) || b.equals(CONTENT_TYPE_BYTELIST)) {
110
+ f = RubyString.newString(runtime, b);
111
+ } else {
112
+ f = RubyString.newStringShared(runtime, HTTP_PREFIX_BYTELIST);
113
+ f.cat(b);
114
+ }
115
+
116
+ b = new ByteList(buffer, value, vlen);
117
+ v = req.fastARef(f);
118
+ if (v == null || v.isNil()) {
119
+ req.fastASet(f, RubyString.newString(runtime, b));
120
+ } else {
121
+ RubyString vs = v.convertToString();
122
+ vs.cat(COMMA_SPACE_BYTELIST);
123
+ vs.cat(b);
124
+ }
125
+ }
126
+
127
+ public static void request_method(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
128
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
129
+ req.fastASet(RubyString.newStringShared(runtime, REQUEST_METHOD_BYTELIST),val);
130
+ }
131
+
132
+ public static void request_uri(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
133
+ validateMaxLength(runtime, length, MAX_REQUEST_URI_LENGTH, MAX_REQUEST_URI_LENGTH_ERR);
134
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
135
+ req.fastASet(RubyString.newStringShared(runtime, REQUEST_URI_BYTELIST),val);
136
+ }
137
+
138
+ public static void fragment(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
139
+ validateMaxLength(runtime, length, MAX_FRAGMENT_LENGTH, MAX_FRAGMENT_LENGTH_ERR);
140
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
141
+ req.fastASet(RubyString.newStringShared(runtime, FRAGMENT_BYTELIST),val);
142
+ }
143
+
144
+ public static void request_path(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
145
+ validateMaxLength(runtime, length, MAX_REQUEST_PATH_LENGTH, MAX_REQUEST_PATH_LENGTH_ERR);
146
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
147
+ req.fastASet(RubyString.newStringShared(runtime, REQUEST_PATH_BYTELIST),val);
148
+ }
149
+
150
+ public static void query_string(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
151
+ validateMaxLength(runtime, length, MAX_QUERY_STRING_LENGTH, MAX_QUERY_STRING_LENGTH_ERR);
152
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
153
+ req.fastASet(RubyString.newStringShared(runtime, QUERY_STRING_BYTELIST),val);
154
+ }
155
+
156
+ public static void server_protocol(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
157
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
158
+ req.fastASet(RubyString.newStringShared(runtime, SERVER_PROTOCOL_BYTELIST),val);
159
+ }
160
+
161
+ public void header_done(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
162
+ body = RubyString.newStringShared(runtime, new ByteList(buffer, at, length));
163
+ }
177
164
 
178
165
  @JRubyMethod
179
166
  public IRubyObject initialize() {
@@ -195,19 +182,24 @@ public class Http11 extends RubyObject {
195
182
 
196
183
  @JRubyMethod
197
184
  public IRubyObject execute(IRubyObject req_hash, IRubyObject data, IRubyObject start) {
198
- int from = 0;
199
- from = RubyNumeric.fix2int(start);
185
+ int from = RubyNumeric.fix2int(start);
200
186
  ByteList d = ((RubyString)data).getByteList();
201
187
  if(from >= d.length()) {
202
- throw new RaiseException(runtime, eHttpParserError, "Requested start is after data buffer end.", true);
188
+ throw newHTTPParserError(runtime, "Requested start is after data buffer end.");
203
189
  } else {
204
- this.hp.parser.data = req_hash;
205
- this.hp.execute(d,from);
206
- validateMaxLength(this.hp.parser.nread,MAX_HEADER_LENGTH, MAX_HEADER_LENGTH_ERR);
207
- if(this.hp.has_error()) {
208
- throw new RaiseException(runtime, eHttpParserError, "Invalid HTTP format, parsing fails.", true);
190
+ Http11Parser hp = this.hp;
191
+ Http11Parser.HttpParser parser = hp.parser;
192
+
193
+ parser.data = (RubyHash) req_hash;
194
+
195
+ hp.execute(runtime, this, d,from);
196
+
197
+ validateMaxLength(runtime, parser.nread,MAX_HEADER_LENGTH, MAX_HEADER_LENGTH_ERR);
198
+
199
+ if(hp.has_error()) {
200
+ throw newHTTPParserError(runtime, "Invalid HTTP format, parsing fails. Are you trying to open an SSL connection to a non-SSL Puma?");
209
201
  } else {
210
- return runtime.newFixnum(this.hp.parser.nread);
202
+ return runtime.newFixnum(parser.nread);
211
203
  }
212
204
  }
213
205
  }
@@ -226,7 +218,7 @@ public class Http11 extends RubyObject {
226
218
  public IRubyObject nread() {
227
219
  return runtime.newFixnum(this.hp.parser.nread);
228
220
  }
229
-
221
+
230
222
  @JRubyMethod
231
223
  public IRubyObject body() {
232
224
  return body;
@@ -2,6 +2,8 @@
2
2
  // line 1 "ext/puma_http11/http11_parser.java.rl"
3
3
  package org.jruby.puma;
4
4
 
5
+ import org.jruby.Ruby;
6
+ import org.jruby.RubyHash;
5
7
  import org.jruby.util.ByteList;
6
8
 
7
9
  public class Http11Parser {
@@ -9,12 +11,12 @@ public class Http11Parser {
9
11
  /** Machine **/
10
12
 
11
13
 
12
- // line 65 "ext/puma_http11/http11_parser.java.rl"
14
+ // line 58 "ext/puma_http11/http11_parser.java.rl"
13
15
 
14
16
 
15
17
  /** Data **/
16
18
 
17
- // line 18 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
19
+ // line 20 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
18
20
  private static byte[] init__puma_parser_actions_0()
19
21
  {
20
22
  return new byte [] {
@@ -32,9 +34,9 @@ private static short[] init__puma_parser_key_offsets_0()
32
34
  {
33
35
  return new short [] {
34
36
  0, 0, 8, 17, 27, 29, 30, 31, 32, 33, 34, 36,
35
- 39, 41, 44, 45, 61, 62, 78, 80, 81, 89, 97, 107,
36
- 115, 125, 134, 142, 150, 159, 168, 177, 186, 195, 204, 213,
37
- 222, 231, 240, 249, 258, 267, 276, 285, 294, 303, 312, 313
37
+ 39, 41, 44, 45, 61, 62, 78, 85, 91, 99, 107, 117,
38
+ 125, 134, 142, 150, 159, 168, 177, 186, 195, 204, 213, 222,
39
+ 231, 240, 249, 258, 267, 276, 285, 294, 303, 312, 313
38
40
  };
39
41
  }
40
42
 
@@ -50,11 +52,11 @@ private static char[] init__puma_parser_trans_keys_0()
50
52
  46, 48, 57, 48, 57, 13, 48, 57, 10, 13, 33, 124,
51
53
  126, 35, 39, 42, 43, 45, 46, 48, 57, 65, 90, 94,
52
54
  122, 10, 33, 58, 124, 126, 35, 39, 42, 43, 45, 46,
53
- 48, 57, 65, 90, 94, 122, 13, 32, 13, 32, 60, 62,
54
- 127, 0, 31, 34, 35, 32, 60, 62, 127, 0, 31, 34,
55
- 35, 43, 58, 45, 46, 48, 57, 65, 90, 97, 122, 32,
56
- 34, 35, 60, 62, 127, 0, 31, 32, 34, 35, 59, 60,
57
- 62, 63, 127, 0, 31, 32, 34, 35, 60, 62, 63, 127,
55
+ 48, 57, 65, 90, 94, 122, 13, 32, 127, 0, 8, 10,
56
+ 31, 13, 127, 0, 8, 10, 31, 32, 60, 62, 127, 0,
57
+ 31, 34, 35, 32, 60, 62, 127, 0, 31, 34, 35, 43,
58
+ 58, 45, 46, 48, 57, 65, 90, 97, 122, 32, 34, 35,
59
+ 60, 62, 127, 0, 31, 32, 34, 35, 60, 62, 63, 127,
58
60
  0, 31, 32, 34, 35, 60, 62, 127, 0, 31, 32, 34,
59
61
  35, 60, 62, 127, 0, 31, 32, 36, 95, 45, 46, 48,
60
62
  57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90,
@@ -81,9 +83,9 @@ private static byte[] init__puma_parser_single_lengths_0()
81
83
  {
82
84
  return new byte [] {
83
85
  0, 2, 3, 4, 2, 1, 1, 1, 1, 1, 0, 1,
84
- 0, 1, 1, 4, 1, 4, 2, 1, 4, 4, 2, 6,
85
- 8, 7, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3,
86
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0
86
+ 0, 1, 1, 4, 1, 4, 3, 2, 4, 4, 2, 6,
87
+ 7, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3,
88
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0
87
89
  };
88
90
  }
89
91
 
@@ -94,9 +96,9 @@ private static byte[] init__puma_parser_range_lengths_0()
94
96
  {
95
97
  return new byte [] {
96
98
  0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1,
97
- 1, 1, 0, 6, 0, 6, 0, 0, 2, 2, 4, 1,
98
- 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3,
99
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0
99
+ 1, 1, 0, 6, 0, 6, 2, 2, 2, 2, 4, 1,
100
+ 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
101
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0
100
102
  };
101
103
  }
102
104
 
@@ -107,9 +109,9 @@ private static short[] init__puma_parser_index_offsets_0()
107
109
  {
108
110
  return new short [] {
109
111
  0, 0, 6, 13, 21, 24, 26, 28, 30, 32, 34, 36,
110
- 39, 41, 44, 46, 57, 59, 70, 73, 75, 82, 89, 96,
111
- 104, 114, 123, 131, 139, 146, 153, 160, 167, 174, 181, 188,
112
- 195, 202, 209, 216, 223, 230, 237, 244, 251, 258, 265, 267
112
+ 39, 41, 44, 46, 57, 59, 70, 76, 81, 88, 95, 102,
113
+ 110, 119, 127, 135, 142, 149, 156, 163, 170, 177, 184, 191,
114
+ 198, 205, 212, 219, 226, 233, 240, 247, 254, 261, 263
113
115
  };
114
116
  }
115
117
 
@@ -125,23 +127,23 @@ private static byte[] init__puma_parser_indicies_0()
125
127
  16, 15, 1, 17, 1, 18, 17, 1, 19, 1, 20, 21,
126
128
  21, 21, 21, 21, 21, 21, 21, 21, 1, 22, 1, 23,
127
129
  24, 23, 23, 23, 23, 23, 23, 23, 23, 1, 26, 27,
128
- 25, 29, 28, 30, 1, 1, 1, 1, 1, 31, 32, 1,
129
- 1, 1, 1, 1, 33, 34, 35, 34, 34, 34, 34, 1,
130
- 8, 1, 9, 1, 1, 1, 1, 35, 36, 1, 38, 39,
131
- 1, 1, 40, 1, 1, 37, 8, 1, 9, 1, 1, 42,
132
- 1, 1, 41, 43, 1, 45, 1, 1, 1, 1, 44, 46,
133
- 1, 48, 1, 1, 1, 1, 47, 2, 49, 49, 49, 49,
134
- 49, 1, 2, 50, 50, 50, 50, 50, 1, 2, 51, 51,
135
- 51, 51, 51, 1, 2, 52, 52, 52, 52, 52, 1, 2,
136
- 53, 53, 53, 53, 53, 1, 2, 54, 54, 54, 54, 54,
137
- 1, 2, 55, 55, 55, 55, 55, 1, 2, 56, 56, 56,
138
- 56, 56, 1, 2, 57, 57, 57, 57, 57, 1, 2, 58,
139
- 58, 58, 58, 58, 1, 2, 59, 59, 59, 59, 59, 1,
140
- 2, 60, 60, 60, 60, 60, 1, 2, 61, 61, 61, 61,
141
- 61, 1, 2, 62, 62, 62, 62, 62, 1, 2, 63, 63,
142
- 63, 63, 63, 1, 2, 64, 64, 64, 64, 64, 1, 2,
143
- 65, 65, 65, 65, 65, 1, 2, 66, 66, 66, 66, 66,
144
- 1, 2, 1, 1, 0
130
+ 1, 1, 1, 25, 29, 1, 1, 1, 28, 30, 1, 1,
131
+ 1, 1, 1, 31, 32, 1, 1, 1, 1, 1, 33, 34,
132
+ 35, 34, 34, 34, 34, 1, 8, 1, 9, 1, 1, 1,
133
+ 1, 35, 36, 1, 38, 1, 1, 39, 1, 1, 37, 40,
134
+ 1, 42, 1, 1, 1, 1, 41, 43, 1, 45, 1, 1,
135
+ 1, 1, 44, 2, 46, 46, 46, 46, 46, 1, 2, 47,
136
+ 47, 47, 47, 47, 1, 2, 48, 48, 48, 48, 48, 1,
137
+ 2, 49, 49, 49, 49, 49, 1, 2, 50, 50, 50, 50,
138
+ 50, 1, 2, 51, 51, 51, 51, 51, 1, 2, 52, 52,
139
+ 52, 52, 52, 1, 2, 53, 53, 53, 53, 53, 1, 2,
140
+ 54, 54, 54, 54, 54, 1, 2, 55, 55, 55, 55, 55,
141
+ 1, 2, 56, 56, 56, 56, 56, 1, 2, 57, 57, 57,
142
+ 57, 57, 1, 2, 58, 58, 58, 58, 58, 1, 2, 59,
143
+ 59, 59, 59, 59, 1, 2, 60, 60, 60, 60, 60, 1,
144
+ 2, 61, 61, 61, 61, 61, 1, 2, 62, 62, 62, 62,
145
+ 62, 1, 2, 63, 63, 63, 63, 63, 1, 2, 1, 1,
146
+ 0
145
147
  };
146
148
  }
147
149
 
@@ -151,12 +153,12 @@ private static final byte _puma_parser_indicies[] = init__puma_parser_indicies_0
151
153
  private static byte[] init__puma_parser_trans_targs_0()
152
154
  {
153
155
  return new byte [] {
154
- 2, 0, 3, 28, 4, 22, 24, 23, 5, 20, 6, 7,
155
- 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 47, 17,
156
+ 2, 0, 3, 27, 4, 22, 24, 23, 5, 20, 6, 7,
157
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 46, 17,
156
158
  18, 19, 14, 18, 19, 14, 5, 21, 5, 21, 22, 23,
157
- 5, 24, 20, 25, 26, 25, 26, 5, 27, 20, 5, 27,
158
- 20, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
159
- 40, 41, 42, 43, 44, 45, 46
159
+ 5, 24, 20, 25, 5, 26, 20, 5, 26, 20, 28, 29,
160
+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
161
+ 42, 43, 44, 45
160
162
  };
161
163
  }
162
164
 
@@ -169,9 +171,9 @@ private static byte[] init__puma_parser_trans_actions_0()
169
171
  1, 0, 11, 0, 1, 1, 1, 1, 13, 13, 1, 0,
170
172
  0, 0, 0, 0, 0, 0, 19, 0, 0, 28, 23, 3,
171
173
  5, 7, 31, 7, 0, 9, 25, 1, 15, 0, 0, 0,
172
- 37, 0, 37, 21, 21, 0, 0, 40, 17, 40, 34, 0,
173
- 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
174
- 0, 0, 0, 0, 0, 0, 0
174
+ 37, 0, 37, 21, 40, 17, 40, 34, 0, 34, 0, 0,
175
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
176
+ 0, 0, 0, 0
175
177
  };
176
178
  }
177
179
 
@@ -179,17 +181,18 @@ private static final byte _puma_parser_trans_actions[] = init__puma_parser_trans
179
181
 
180
182
 
181
183
  static final int puma_parser_start = 1;
182
- static final int puma_parser_first_final = 47;
184
+ static final int puma_parser_first_final = 46;
183
185
  static final int puma_parser_error = 0;
184
186
 
185
- // line 69 "ext/puma_http11/http11_parser.java.rl"
187
+
188
+ // line 62 "ext/puma_http11/http11_parser.java.rl"
186
189
 
187
190
  public static interface ElementCB {
188
- public void call(Object data, int at, int length);
191
+ public void call(Ruby runtime, RubyHash data, ByteList buffer, int at, int length);
189
192
  }
190
193
 
191
194
  public static interface FieldCB {
192
- public void call(Object data, int field, int flen, int value, int vlen);
195
+ public void call(Ruby runtime, RubyHash data, ByteList buffer, int field, int flen, int value, int vlen);
193
196
  }
194
197
 
195
198
  public static class HttpParser {
@@ -202,28 +205,19 @@ static final int puma_parser_error = 0;
202
205
  int field_len;
203
206
  int query_start;
204
207
 
205
- Object data;
208
+ RubyHash data;
206
209
  ByteList buffer;
207
210
 
208
- public FieldCB http_field;
209
- public ElementCB request_method;
210
- public ElementCB request_uri;
211
- public ElementCB fragment;
212
- public ElementCB request_path;
213
- public ElementCB query_string;
214
- public ElementCB http_version;
215
- public ElementCB header_done;
216
-
217
211
  public void init() {
218
212
  cs = 0;
219
213
 
220
-
221
- // line 225 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
214
+
215
+ // line 216 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
222
216
  {
223
217
  cs = puma_parser_start;
224
218
  }
225
219
 
226
- // line 104 "ext/puma_http11/http11_parser.java.rl"
220
+ // line 88 "ext/puma_http11/http11_parser.java.rl"
227
221
 
228
222
  body_start = 0;
229
223
  content_len = 0;
@@ -236,7 +230,7 @@ static final int puma_parser_error = 0;
236
230
 
237
231
  public final HttpParser parser = new HttpParser();
238
232
 
239
- public int execute(ByteList buffer, int off) {
233
+ public int execute(Ruby runtime, Http11 http, ByteList buffer, int off) {
240
234
  int p, pe;
241
235
  int cs = parser.cs;
242
236
  int len = buffer.length();
@@ -249,8 +243,8 @@ static final int puma_parser_error = 0;
249
243
  byte[] data = buffer.bytes();
250
244
  parser.buffer = buffer;
251
245
 
252
-
253
- // line 257 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
246
+
247
+ // line 248 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
254
248
  {
255
249
  int _klen;
256
250
  int _trans = 0;
@@ -331,91 +325,82 @@ case 1:
331
325
  switch ( _puma_parser_actions[_acts++] )
332
326
  {
333
327
  case 0:
334
- // line 13 "ext/puma_http11/http11_parser.java.rl"
328
+ // line 15 "ext/puma_http11/http11_parser.java.rl"
335
329
  {parser.mark = p; }
336
330
  break;
337
331
  case 1:
338
- // line 15 "ext/puma_http11/http11_parser.java.rl"
332
+ // line 17 "ext/puma_http11/http11_parser.java.rl"
339
333
  { parser.field_start = p; }
340
334
  break;
341
335
  case 2:
342
- // line 16 "ext/puma_http11/http11_parser.java.rl"
336
+ // line 18 "ext/puma_http11/http11_parser.java.rl"
343
337
  { /* FIXME stub */ }
344
338
  break;
345
339
  case 3:
346
- // line 17 "ext/puma_http11/http11_parser.java.rl"
347
- {
340
+ // line 19 "ext/puma_http11/http11_parser.java.rl"
341
+ {
348
342
  parser.field_len = p-parser.field_start;
349
343
  }
350
344
  break;
351
345
  case 4:
352
- // line 21 "ext/puma_http11/http11_parser.java.rl"
346
+ // line 23 "ext/puma_http11/http11_parser.java.rl"
353
347
  { parser.mark = p; }
354
348
  break;
355
349
  case 5:
356
- // line 22 "ext/puma_http11/http11_parser.java.rl"
350
+ // line 24 "ext/puma_http11/http11_parser.java.rl"
357
351
  {
358
- if(parser.http_field != null) {
359
- parser.http_field.call(parser.data, parser.field_start, parser.field_len, parser.mark, p-parser.mark);
360
- }
352
+ Http11.http_field(runtime, parser.data, parser.buffer, parser.field_start, parser.field_len, parser.mark, p-parser.mark);
361
353
  }
362
354
  break;
363
355
  case 6:
364
356
  // line 27 "ext/puma_http11/http11_parser.java.rl"
365
357
  {
366
- if(parser.request_method != null)
367
- parser.request_method.call(parser.data, parser.mark, p-parser.mark);
358
+ Http11.request_method(runtime, parser.data, parser.buffer, parser.mark, p-parser.mark);
368
359
  }
369
360
  break;
370
361
  case 7:
371
- // line 31 "ext/puma_http11/http11_parser.java.rl"
362
+ // line 30 "ext/puma_http11/http11_parser.java.rl"
372
363
  {
373
- if(parser.request_uri != null)
374
- parser.request_uri.call(parser.data, parser.mark, p-parser.mark);
364
+ Http11.request_uri(runtime, parser.data, parser.buffer, parser.mark, p-parser.mark);
375
365
  }
376
366
  break;
377
367
  case 8:
378
- // line 35 "ext/puma_http11/http11_parser.java.rl"
368
+ // line 33 "ext/puma_http11/http11_parser.java.rl"
379
369
  {
380
- if(parser.fragment != null)
381
- parser.fragment.call(parser.data, parser.mark, p-parser.mark);
370
+ Http11.fragment(runtime, parser.data, parser.buffer, parser.mark, p-parser.mark);
382
371
  }
383
372
  break;
384
373
  case 9:
385
- // line 40 "ext/puma_http11/http11_parser.java.rl"
374
+ // line 37 "ext/puma_http11/http11_parser.java.rl"
386
375
  {parser.query_start = p; }
387
376
  break;
388
377
  case 10:
389
- // line 41 "ext/puma_http11/http11_parser.java.rl"
378
+ // line 38 "ext/puma_http11/http11_parser.java.rl"
390
379
  {
391
- if(parser.query_string != null)
392
- parser.query_string.call(parser.data, parser.query_start, p-parser.query_start);
380
+ Http11.query_string(runtime, parser.data, parser.buffer, parser.query_start, p-parser.query_start);
393
381
  }
394
382
  break;
395
383
  case 11:
396
- // line 46 "ext/puma_http11/http11_parser.java.rl"
384
+ // line 42 "ext/puma_http11/http11_parser.java.rl"
397
385
  {
398
- if(parser.http_version != null)
399
- parser.http_version.call(parser.data, parser.mark, p-parser.mark);
386
+ Http11.server_protocol(runtime, parser.data, parser.buffer, parser.mark, p-parser.mark);
400
387
  }
401
388
  break;
402
389
  case 12:
403
- // line 51 "ext/puma_http11/http11_parser.java.rl"
390
+ // line 46 "ext/puma_http11/http11_parser.java.rl"
404
391
  {
405
- if(parser.request_path != null)
406
- parser.request_path.call(parser.data, parser.mark, p-parser.mark);
392
+ Http11.request_path(runtime, parser.data, parser.buffer, parser.mark, p-parser.mark);
407
393
  }
408
394
  break;
409
395
  case 13:
410
- // line 56 "ext/puma_http11/http11_parser.java.rl"
411
- {
396
+ // line 50 "ext/puma_http11/http11_parser.java.rl"
397
+ {
412
398
  parser.body_start = p + 1;
413
- if(parser.header_done != null)
414
- parser.header_done.call(parser.data, p + 1, pe - p - 1);
399
+ http.header_done(runtime, parser.data, parser.buffer, p + 1, pe - p - 1);
415
400
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
416
401
  }
417
402
  break;
418
- // line 422 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
403
+ // line 404 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
419
404
  }
420
405
  }
421
406
  }
@@ -435,11 +420,11 @@ case 5:
435
420
  break; }
436
421
  }
437
422
 
438
- // line 130 "ext/puma_http11/http11_parser.java.rl"
423
+ // line 114 "ext/puma_http11/http11_parser.java.rl"
439
424
 
440
425
  parser.cs = cs;
441
426
  parser.nread += (p - off);
442
-
427
+
443
428
  assert p <= pe : "buffer overflow after parsing execute";
444
429
  assert parser.nread <= len : "nread longer than length";
445
430
  assert parser.body_start <= len : "body starts after buffer end";