ed-precompiled_puma 7.0.4

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 (88) hide show
  1. checksums.yaml +7 -0
  2. data/History.md +3172 -0
  3. data/LICENSE +29 -0
  4. data/README.md +477 -0
  5. data/bin/puma +10 -0
  6. data/bin/puma-wild +25 -0
  7. data/bin/pumactl +12 -0
  8. data/docs/architecture.md +74 -0
  9. data/docs/compile_options.md +55 -0
  10. data/docs/deployment.md +102 -0
  11. data/docs/fork_worker.md +41 -0
  12. data/docs/images/puma-connection-flow-no-reactor.png +0 -0
  13. data/docs/images/puma-connection-flow.png +0 -0
  14. data/docs/images/puma-general-arch.png +0 -0
  15. data/docs/java_options.md +54 -0
  16. data/docs/jungle/README.md +9 -0
  17. data/docs/jungle/rc.d/README.md +74 -0
  18. data/docs/jungle/rc.d/puma +61 -0
  19. data/docs/jungle/rc.d/puma.conf +10 -0
  20. data/docs/kubernetes.md +80 -0
  21. data/docs/nginx.md +80 -0
  22. data/docs/plugins.md +42 -0
  23. data/docs/rails_dev_mode.md +28 -0
  24. data/docs/restart.md +65 -0
  25. data/docs/signals.md +98 -0
  26. data/docs/stats.md +148 -0
  27. data/docs/systemd.md +253 -0
  28. data/docs/testing_benchmarks_local_files.md +150 -0
  29. data/docs/testing_test_rackup_ci_files.md +36 -0
  30. data/ext/puma_http11/PumaHttp11Service.java +17 -0
  31. data/ext/puma_http11/ext_help.h +15 -0
  32. data/ext/puma_http11/extconf.rb +65 -0
  33. data/ext/puma_http11/http11_parser.c +1057 -0
  34. data/ext/puma_http11/http11_parser.h +65 -0
  35. data/ext/puma_http11/http11_parser.java.rl +145 -0
  36. data/ext/puma_http11/http11_parser.rl +149 -0
  37. data/ext/puma_http11/http11_parser_common.rl +54 -0
  38. data/ext/puma_http11/mini_ssl.c +852 -0
  39. data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
  40. data/ext/puma_http11/org/jruby/puma/Http11.java +257 -0
  41. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +455 -0
  42. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +509 -0
  43. data/ext/puma_http11/puma_http11.c +507 -0
  44. data/lib/puma/app/status.rb +96 -0
  45. data/lib/puma/binder.rb +511 -0
  46. data/lib/puma/cli.rb +245 -0
  47. data/lib/puma/client.rb +720 -0
  48. data/lib/puma/cluster/worker.rb +182 -0
  49. data/lib/puma/cluster/worker_handle.rb +127 -0
  50. data/lib/puma/cluster.rb +635 -0
  51. data/lib/puma/cluster_accept_loop_delay.rb +91 -0
  52. data/lib/puma/commonlogger.rb +115 -0
  53. data/lib/puma/configuration.rb +452 -0
  54. data/lib/puma/const.rb +307 -0
  55. data/lib/puma/control_cli.rb +320 -0
  56. data/lib/puma/detect.rb +47 -0
  57. data/lib/puma/dsl.rb +1480 -0
  58. data/lib/puma/error_logger.rb +115 -0
  59. data/lib/puma/events.rb +72 -0
  60. data/lib/puma/io_buffer.rb +50 -0
  61. data/lib/puma/jruby_restart.rb +11 -0
  62. data/lib/puma/json_serialization.rb +96 -0
  63. data/lib/puma/launcher/bundle_pruner.rb +104 -0
  64. data/lib/puma/launcher.rb +496 -0
  65. data/lib/puma/log_writer.rb +147 -0
  66. data/lib/puma/minissl/context_builder.rb +96 -0
  67. data/lib/puma/minissl.rb +463 -0
  68. data/lib/puma/null_io.rb +101 -0
  69. data/lib/puma/plugin/systemd.rb +90 -0
  70. data/lib/puma/plugin/tmp_restart.rb +36 -0
  71. data/lib/puma/plugin.rb +111 -0
  72. data/lib/puma/rack/builder.rb +297 -0
  73. data/lib/puma/rack/urlmap.rb +93 -0
  74. data/lib/puma/rack_default.rb +24 -0
  75. data/lib/puma/reactor.rb +140 -0
  76. data/lib/puma/request.rb +701 -0
  77. data/lib/puma/runner.rb +211 -0
  78. data/lib/puma/sd_notify.rb +146 -0
  79. data/lib/puma/server.rb +734 -0
  80. data/lib/puma/single.rb +72 -0
  81. data/lib/puma/state_file.rb +69 -0
  82. data/lib/puma/thread_pool.rb +402 -0
  83. data/lib/puma/util.rb +134 -0
  84. data/lib/puma.rb +93 -0
  85. data/lib/rack/handler/puma.rb +144 -0
  86. data/tools/Dockerfile +18 -0
  87. data/tools/trickletest.rb +44 -0
  88. metadata +152 -0
@@ -0,0 +1,15 @@
1
+ package puma;
2
+
3
+ import java.io.IOException;
4
+
5
+ import org.jruby.Ruby;
6
+ import org.jruby.runtime.load.BasicLibraryService;
7
+
8
+ import org.jruby.puma.Http11;
9
+
10
+ public class PumaHttp11Service implements BasicLibraryService {
11
+ public boolean basicLoad(final Ruby runtime) throws IOException {
12
+ Http11.createHttp11(runtime);
13
+ return true;
14
+ }
15
+ }
@@ -0,0 +1,257 @@
1
+ package org.jruby.puma;
2
+
3
+ import org.jruby.Ruby;
4
+ import org.jruby.RubyClass;
5
+ import org.jruby.RubyHash;
6
+ import org.jruby.RubyModule;
7
+ import org.jruby.RubyNumeric;
8
+ import org.jruby.RubyObject;
9
+ import org.jruby.RubyString;
10
+
11
+ import org.jruby.anno.JRubyMethod;
12
+
13
+ import org.jruby.runtime.ObjectAllocator;
14
+ import org.jruby.runtime.builtin.IRubyObject;
15
+
16
+ import org.jruby.exceptions.RaiseException;
17
+
18
+ import org.jruby.util.ByteList;
19
+
20
+ /**
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
+ */
24
+ public class Http11 extends RubyObject {
25
+ public final static int MAX_FIELD_NAME_LENGTH = 256;
26
+ public final static String MAX_FIELD_NAME_LENGTH_ERR = "HTTP element FIELD_NAME is longer than the 256 allowed length.";
27
+ public final static int MAX_FIELD_VALUE_LENGTH = 80 * 1024;
28
+ public final static String MAX_FIELD_VALUE_LENGTH_ERR = "HTTP element FIELD_VALUE is longer than the 81920 allowed length.";
29
+ public final static int MAX_REQUEST_URI_LENGTH = getConstLength("PUMA_REQUEST_URI_MAX_LENGTH", 1024 * 12);
30
+ public final static String MAX_REQUEST_URI_LENGTH_ERR = "HTTP element REQUEST_URI is longer than the " + MAX_REQUEST_URI_LENGTH + " allowed length.";
31
+ public final static int MAX_FRAGMENT_LENGTH = 1024;
32
+ public final static String MAX_FRAGMENT_LENGTH_ERR = "HTTP element FRAGMENT is longer than the 1024 allowed length.";
33
+ public final static int MAX_REQUEST_PATH_LENGTH = getConstLength("PUMA_REQUEST_PATH_MAX_LENGTH", 8192);
34
+ public final static String MAX_REQUEST_PATH_LENGTH_ERR = "HTTP element REQUEST_PATH is longer than the " + MAX_REQUEST_PATH_LENGTH + " allowed length.";
35
+ public final static int MAX_QUERY_STRING_LENGTH = getConstLength("PUMA_QUERY_STRING_MAX_LENGTH", 10 * 1024);
36
+ public final static String MAX_QUERY_STRING_LENGTH_ERR = "HTTP element QUERY_STRING is longer than the " + MAX_QUERY_STRING_LENGTH +" allowed length.";
37
+ public final static int MAX_HEADER_LENGTH = 1024 * (80 + 32);
38
+ public final static String MAX_HEADER_LENGTH_ERR = "HTTP element HEADER is longer than the 114688 allowed length.";
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"));
50
+
51
+ public static String getEnvOrProperty(String name) {
52
+ String envValue = System.getenv(name);
53
+ return (envValue != null) ? envValue : System.getProperty(name);
54
+ }
55
+
56
+ public static int getConstLength(String name, Integer defaultValue) {
57
+ String stringValue = getEnvOrProperty(name);
58
+ if (stringValue == null || stringValue.isEmpty()) return defaultValue;
59
+
60
+ try {
61
+ int value = Integer.parseUnsignedInt(stringValue);
62
+ if (value <= 0) {
63
+ throw new NumberFormatException("The number is not positive.");
64
+ }
65
+ return value;
66
+ } catch (NumberFormatException e) {
67
+ System.err.println(String.format("The value %s for %s is invalid. Using default value %d instead.", stringValue, name, defaultValue));
68
+ return defaultValue;
69
+ }
70
+ }
71
+
72
+ private static ObjectAllocator ALLOCATOR = new ObjectAllocator() {
73
+ public IRubyObject allocate(Ruby runtime, RubyClass klass) {
74
+ return new Http11(runtime, klass);
75
+ }
76
+ };
77
+
78
+ public static void createHttp11(Ruby runtime) {
79
+ RubyModule mPuma = runtime.defineModule("Puma");
80
+ mPuma.defineClassUnder("HttpParserError",runtime.getClass("StandardError"),runtime.getClass("StandardError").getAllocator());
81
+
82
+ RubyClass cHttpParser = mPuma.defineClassUnder("HttpParser",runtime.getObject(),ALLOCATOR);
83
+ cHttpParser.defineAnnotatedMethods(Http11.class);
84
+ }
85
+
86
+ private Ruby runtime;
87
+ private Http11Parser hp;
88
+ private RubyString body;
89
+
90
+ public Http11(Ruby runtime, RubyClass clazz) {
91
+ super(runtime,clazz);
92
+ this.runtime = runtime;
93
+ this.hp = new Http11Parser();
94
+ this.hp.parser.init();
95
+ }
96
+
97
+ public static void validateMaxLength(Ruby runtime, int len, int max, String msg) {
98
+ if(len>max) {
99
+ throw newHTTPParserError(runtime, msg);
100
+ }
101
+ }
102
+
103
+ private static RaiseException newHTTPParserError(Ruby runtime, String msg) {
104
+ return runtime.newRaiseException(getHTTPParserError(runtime), msg);
105
+ }
106
+
107
+ private static RubyClass getHTTPParserError(Ruby runtime) {
108
+ // Cheaper to look this up lazily than cache eagerly and consume a field, since it's rarely encountered
109
+ return (RubyClass)runtime.getModule("Puma").getConstant("HttpParserError");
110
+ }
111
+
112
+ private static boolean is_ows(int c) {
113
+ return c == ' ' || c == '\t';
114
+ }
115
+
116
+ public static void http_field(Ruby runtime, RubyHash req, ByteList buffer, int field, int flen, int value, int vlen) {
117
+ RubyString f;
118
+ IRubyObject v;
119
+ validateMaxLength(runtime, flen, MAX_FIELD_NAME_LENGTH, MAX_FIELD_NAME_LENGTH_ERR);
120
+ validateMaxLength(runtime, vlen, MAX_FIELD_VALUE_LENGTH, MAX_FIELD_VALUE_LENGTH_ERR);
121
+
122
+ ByteList b = new ByteList(buffer,field,flen);
123
+ for(int i = 0,j = b.length();i<j;i++) {
124
+ int bite = b.get(i) & 0xFF;
125
+ if(bite == '-') {
126
+ b.set(i, (byte)'_');
127
+ } else if(bite == '_') {
128
+ b.set(i, (byte)',');
129
+ } else {
130
+ b.set(i, (byte)Character.toUpperCase(bite));
131
+ }
132
+ }
133
+
134
+ while (vlen > 0 && is_ows(buffer.get(value + vlen - 1))) vlen--;
135
+ while (vlen > 0 && is_ows(buffer.get(value))) {
136
+ vlen--;
137
+ value++;
138
+ }
139
+
140
+ if (b.equals(CONTENT_LENGTH_BYTELIST) || b.equals(CONTENT_TYPE_BYTELIST)) {
141
+ f = RubyString.newString(runtime, b);
142
+ } else {
143
+ f = RubyString.newStringShared(runtime, HTTP_PREFIX_BYTELIST);
144
+ f.cat(b);
145
+ }
146
+
147
+ b = new ByteList(buffer, value, vlen);
148
+ v = req.fastARef(f);
149
+ if (v == null || v.isNil()) {
150
+ req.fastASet(f, RubyString.newString(runtime, b));
151
+ } else {
152
+ RubyString vs = v.convertToString();
153
+ vs.cat(COMMA_SPACE_BYTELIST);
154
+ vs.cat(b);
155
+ }
156
+ }
157
+
158
+ public static void request_method(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
159
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
160
+ req.fastASet(RubyString.newStringShared(runtime, REQUEST_METHOD_BYTELIST),val);
161
+ }
162
+
163
+ public static void request_uri(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
164
+ validateMaxLength(runtime, length, MAX_REQUEST_URI_LENGTH, MAX_REQUEST_URI_LENGTH_ERR);
165
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
166
+ req.fastASet(RubyString.newStringShared(runtime, REQUEST_URI_BYTELIST),val);
167
+ }
168
+
169
+ public static void fragment(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
170
+ validateMaxLength(runtime, length, MAX_FRAGMENT_LENGTH, MAX_FRAGMENT_LENGTH_ERR);
171
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
172
+ req.fastASet(RubyString.newStringShared(runtime, FRAGMENT_BYTELIST),val);
173
+ }
174
+
175
+ public static void request_path(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
176
+ validateMaxLength(runtime, length, MAX_REQUEST_PATH_LENGTH, MAX_REQUEST_PATH_LENGTH_ERR);
177
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
178
+ req.fastASet(RubyString.newStringShared(runtime, REQUEST_PATH_BYTELIST),val);
179
+ }
180
+
181
+ public static void query_string(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
182
+ validateMaxLength(runtime, length, MAX_QUERY_STRING_LENGTH, MAX_QUERY_STRING_LENGTH_ERR);
183
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
184
+ req.fastASet(RubyString.newStringShared(runtime, QUERY_STRING_BYTELIST),val);
185
+ }
186
+
187
+ public static void server_protocol(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
188
+ RubyString val = RubyString.newString(runtime,new ByteList(buffer,at,length));
189
+ req.fastASet(RubyString.newStringShared(runtime, SERVER_PROTOCOL_BYTELIST),val);
190
+ }
191
+
192
+ public void header_done(Ruby runtime, RubyHash req, ByteList buffer, int at, int length) {
193
+ body = RubyString.newStringShared(runtime, new ByteList(buffer, at, length));
194
+ }
195
+
196
+ @JRubyMethod
197
+ public IRubyObject initialize() {
198
+ this.hp.parser.init();
199
+ return this;
200
+ }
201
+
202
+ @JRubyMethod
203
+ public IRubyObject reset() {
204
+ this.hp.parser.init();
205
+ return runtime.getNil();
206
+ }
207
+
208
+ @JRubyMethod
209
+ public IRubyObject finish() {
210
+ this.hp.finish();
211
+ return this.hp.is_finished() ? runtime.getTrue() : runtime.getFalse();
212
+ }
213
+
214
+ @JRubyMethod
215
+ public IRubyObject execute(IRubyObject req_hash, IRubyObject data, IRubyObject start) {
216
+ int from = RubyNumeric.fix2int(start);
217
+ ByteList d = ((RubyString)data).getByteList();
218
+ if(from >= d.length()) {
219
+ throw newHTTPParserError(runtime, "Requested start is after data buffer end.");
220
+ } else {
221
+ Http11Parser hp = this.hp;
222
+ Http11Parser.HttpParser parser = hp.parser;
223
+
224
+ parser.data = (RubyHash) req_hash;
225
+
226
+ hp.execute(runtime, this, d,from);
227
+
228
+ validateMaxLength(runtime, parser.nread,MAX_HEADER_LENGTH, MAX_HEADER_LENGTH_ERR);
229
+
230
+ if(hp.has_error()) {
231
+ throw newHTTPParserError(runtime, "Invalid HTTP format, parsing fails. Are you trying to open an SSL connection to a non-SSL Puma?");
232
+ } else {
233
+ return runtime.newFixnum(parser.nread);
234
+ }
235
+ }
236
+ }
237
+
238
+ @JRubyMethod(name = "error?")
239
+ public IRubyObject has_error() {
240
+ return this.hp.has_error() ? runtime.getTrue() : runtime.getFalse();
241
+ }
242
+
243
+ @JRubyMethod(name = "finished?")
244
+ public IRubyObject is_finished() {
245
+ return this.hp.is_finished() ? runtime.getTrue() : runtime.getFalse();
246
+ }
247
+
248
+ @JRubyMethod
249
+ public IRubyObject nread() {
250
+ return runtime.newFixnum(this.hp.parser.nread);
251
+ }
252
+
253
+ @JRubyMethod
254
+ public IRubyObject body() {
255
+ return body;
256
+ }
257
+ }// Http11