puma 4.0.1-java → 4.1.0-java

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9afa58278b2e60192f5599f0c15f2120cfc0bb37c06a1b4da49aa070c0826572
4
- data.tar.gz: ff3845c2bbe123ff2d8e8294807248fb75f428c13481665094f0cc3c3d6aa43f
3
+ metadata.gz: 7dac51ad5fcb659c08fb2bf59c206b7805e9853d348783414a260c0ccbe01ed5
4
+ data.tar.gz: 62abcd5a97888b7c2e8c236987588138217f024a6471410156f7077cc920f839
5
5
  SHA512:
6
- metadata.gz: dd4a38dfa08be4327025f310c5ab14fe55e95fc6e9775b301d1fe0c9780e25daca5fd198bea82eaba6e8ce05d29c88edba934d4323598e6cc43187bb26d673e2
7
- data.tar.gz: '0847d1628c4478ddb8575dc5daec0fb924cc6f87a779cb5960b0f08b22f1620a648e0b5724194f58ba4be1a9403619f08b9dbb45f40c983b9e5f59a709e4d780'
6
+ metadata.gz: 3b5adbfb751509e3bbed09ba4946e4ba3fb71341cbdae78b79c8cabce89446b31af37609ea910295c6ffe3827fc6cfcf367028cb7614a9e89211396f52d3f07e
7
+ data.tar.gz: ad02001dd4a0e596209ab4a2238b7b6e9e2ca35c21926d30346c5c40669264b8e2647bfff7c5cf1b06924b13ba1cc002e5e7a62d799921f0e838c6ccf14e4324
data/History.md CHANGED
@@ -6,11 +6,39 @@
6
6
  * Bugfixes
7
7
  * Your bugfix goes here (#Github Number)
8
8
 
9
+ ## 4.1.0 / 2019-08-08
10
+
11
+ * 4 features
12
+ * Add REQUEST_PATH on parse error message (#1831)
13
+ * You can now easily add custom log formatters with the `log_formatter` config option (#1816)
14
+ * Puma.stats now provides process start times (#1844)
15
+ * Add support for disabling TLSv1.1 (#1836)
16
+
17
+ * 7 bugfixes
18
+ * Fix issue where Puma was creating zombie process entries (#1887)
19
+ * Fix bugs with line-endings and chunked encoding (#1812)
20
+ * RACK_URL_SCHEME is now set correctly in all conditions (#1491)
21
+ * We no longer mutate global STDOUT/STDERR, particularly the sync setting (#1837)
22
+ * SSL read_nonblock no longer blocks (#1857)
23
+ * Swallow connection errors when sending early hints (#1822)
24
+ * Backtrace no longer dumped when invalid pumactl commands are run (#1863)
25
+
26
+ * 5 other
27
+ * Avoid casting worker_timeout twice (#1838)
28
+ * Removed a call to private that wasn't doing anything (#1882)
29
+ * README, Rakefile, docs and test cleanups (#1848, #1847, #1846, #1853, #1859, #1850, #1866, #1870, #1872, #1833, #1888)
30
+ * Puma.io has proper documentation now (https://puma.io/puma/)
31
+ * Added the Contributor Covenant CoC
32
+
33
+ * 1 known issue
34
+ * Some users are still experiencing issues surrounding socket activation and Unix sockets (#1842)
35
+
9
36
  ## 4.0.1 / 2019-07-11
10
37
 
11
38
  * 2 bugfixes
12
39
  * Fix socket removed after reload - should fix problems with systemd socket activation. (#1829)
13
40
  * Add extconf tests for DTLS_method & TLS_server_method, use in minissl.rb. Should fix "undefined symbol: DTLS_method" when compiling against old OpenSSL versions. (#1832)
41
+ * 1 other
14
42
  * Removed unnecessary RUBY_VERSION checks. (#1827)
15
43
 
16
44
  ## 4.0.0 / 2019-06-25
data/README.md CHANGED
@@ -10,36 +10,38 @@
10
10
  [![Code Climate](https://codeclimate.com/github/puma/puma.svg)](https://codeclimate.com/github/puma/puma)
11
11
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=puma&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=puma&package-manager=bundler&version-scheme=semver)
12
12
 
13
- Puma is a **simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications** in development and production.
13
+ Puma is a **simple, fast, multi-threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications**.
14
14
 
15
15
  ## Built For Speed & Concurrency
16
16
 
17
- Under the hood, Puma processes requests using a C-optimized Ragel extension (inherited from Mongrel) that provides fast, accurate HTTP 1.1 protocol parsing in a portable way. Puma then serves the request in a thread from an internal thread pool. Since each request is served in a separate thread, truly concurrent Ruby implementations (JRuby, Rubinius) will use all available CPU cores.
17
+ Puma processes requests using a C-optimized Ragel extension (inherited from Mongrel) that provides fast, accurate HTTP 1.1 protocol parsing in a portable way. Puma then serves the request using a thread pool. Each request is served in a separate thread, so truly concurrent Ruby implementations (JRuby, Rubinius) will use all available CPU cores.
18
18
 
19
19
  Puma was designed to be the go-to server for [Rubinius](https://rubini.us), but also works well with JRuby and MRI.
20
20
 
21
- On MRI, there is a Global VM Lock (GVL) that ensures only one thread can run Ruby code at a time. But if you're doing a lot of blocking IO (such as HTTP calls to external APIs like Twitter), Puma still improves MRI's throughput by allowing blocking IO to be run concurrently.
21
+ On MRI, there is a Global VM Lock (GVL) that ensures only one thread can run Ruby code at a time. But if you're doing a lot of blocking IO (such as HTTP calls to external APIs like Twitter), Puma still improves MRI's throughput by allowing IO waiting to be done in parallel.
22
22
 
23
23
  ## Quick Start
24
24
 
25
25
  ```
26
26
  $ gem install puma
27
- $ puma <any rackup (*.ru) file>
27
+ $ puma
28
28
  ```
29
29
 
30
+ Without arguments, puma will look for a rackup (.ru) file in the current working directory called `config.ru`.
31
+
30
32
  ## Frameworks
31
33
 
32
34
  ### Rails
33
35
 
34
- Puma is the default server for Rails, and should already be included in your Gemfile.
36
+ Puma is the default server for Rails, included in the generated Gemfile.
35
37
 
36
- Then start your server with the `rails` command:
38
+ Start your server with the `rails` command:
37
39
 
38
40
  ```
39
- $ rails s
41
+ $ rails server
40
42
  ```
41
43
 
42
- Many configuration options are not available when using `rails s`. It is recommended that you use Puma's executable instead:
44
+ Many configuration options and Puma features are not available when using `rails server`. It is recommended that you use Puma's executable instead:
43
45
 
44
46
  ```
45
47
  $ bundle exec puma
@@ -53,7 +55,7 @@ You can run your Sinatra application with Puma from the command line like this:
53
55
  $ ruby app.rb -s Puma
54
56
  ```
55
57
 
56
- Or you can configure your application to always use Puma:
58
+ Or you can configure your Sinatra application to always use Puma:
57
59
 
58
60
  ```ruby
59
61
  require 'sinatra'
@@ -64,6 +66,9 @@ configure { set :server, :puma }
64
66
 
65
67
  Puma provides numerous options. Consult `puma -h` (or `puma --help`) for a full list of CLI options, or see [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb).
66
68
 
69
+ You can also find several configuration examples as part of the
70
+ [test](test/config) suite.
71
+
67
72
  ### Thread Pool
68
73
 
69
74
  Puma uses a thread pool. You can set the minimum and maximum number of threads that are available in the pool with the `-t` (or `--threads`) flag:
@@ -72,9 +77,9 @@ Puma uses a thread pool. You can set the minimum and maximum number of threads t
72
77
  $ puma -t 8:32
73
78
  ```
74
79
 
75
- Puma will automatically scale the number of threads, from the minimum until it caps out at the maximum, based on how much traffic is present. The current default is `0:16`. Feel free to experiment, but be careful not to set the number of maximum threads to a large number, as you may exhaust resources on the system (or hit resource limits).
80
+ Puma will automatically scale the number of threads, from the minimum until it caps out at the maximum, based on how much traffic is present. The current default is `0:16`. Feel free to experiment, but be careful not to set the number of maximum threads to a large number, as you may exhaust resources on the system (or cause contention for the Global VM Lock, when using MRI).
76
81
 
77
- Be aware that additionally Puma creates threads on its own for internal purposes (e.g. handling slow clients). So even if you specify -t 1:1, expect around 7 threads created in your application.
82
+ Be aware that additionally Puma creates threads on its own for internal purposes (e.g. handling slow clients). So, even if you specify -t 1:1, expect around 7 threads created in your application.
78
83
 
79
84
  ### Clustered mode
80
85
 
@@ -84,9 +89,9 @@ Puma also offers "clustered mode". Clustered mode `fork`s workers from a master
84
89
  $ puma -t 8:32 -w 3
85
90
  ```
86
91
 
87
- Note that threads are still used in clustered mode, and the `-t` thread flag setting is per worker, so `-w 2 -t 16:16` will spawn 32 threads in total.
92
+ Note that threads are still used in clustered mode, and the `-t` thread flag setting is per worker, so `-w 2 -t 16:16` will spawn 32 threads in total, with 16 in each worker process.
88
93
 
89
- In clustered mode, Puma may "preload" your application. This loads all the application code *prior* to forking. Preloading reduces total memory usage of your application via an operating system feature called [copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write) (Ruby 2.0+ only). Use the `--preload` flag from the command line:
94
+ In clustered mode, Puma can "preload" your application. This loads all the application code *prior* to forking. Preloading reduces total memory usage of your application via an operating system feature called [copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write) (Ruby 2.0+ only). Use the `--preload` flag from the command line:
90
95
 
91
96
  ```
92
97
  $ puma -w 3 --preload
@@ -111,8 +116,7 @@ end
111
116
 
112
117
  This code can be used to setup the process before booting the application, allowing
113
118
  you to do some Puma-specific things that you don't want to embed in your application.
114
- For instance, you could fire a log notification that a worker booted or send something to statsd.
115
- This can be called multiple times.
119
+ For instance, you could fire a log notification that a worker booted or send something to statsd. This can be called multiple times.
116
120
 
117
121
  If you're preloading your application and using ActiveRecord, it's recommended that you setup your connection pool here:
118
122
 
@@ -125,7 +129,7 @@ on_worker_boot do
125
129
  end
126
130
  ```
127
131
 
128
- On top of that, you can specify a block in your configuration file that will be run before workers are forked:
132
+ `before_fork` specifies a block to be run before workers are forked:
129
133
 
130
134
  ```ruby
131
135
  # config/puma.rb
@@ -136,15 +140,29 @@ end
136
140
 
137
141
  Preloading can’t be used with phased restart, since phased restart kills and restarts workers one-by-one, and preload_app copies the code of master into the workers.
138
142
 
143
+ ### Error handling
144
+
145
+ If puma encounters an error outside of the context of your application, it will respond with a 500 and a simple
146
+ textual error message (see `lowlevel_error` in [this file](https://github.com/puma/puma/blob/master/lib/puma/server.rb)).
147
+ You can specify custom behavior for this scenario. For example, you can report the error to your third-party
148
+ error-tracking service (in this example, [rollbar](http://rollbar.com)):
149
+
150
+ ```ruby
151
+ lowlevel_error_handler do |e|
152
+ Rollbar.critical(e)
153
+ [500, {}, ["An error has occurred, and engineers have been informed. Please reload the page. If you continue to have problems, contact support@example.com\n"]]
154
+ end
155
+ ```
156
+
139
157
  ### Binding TCP / Sockets
140
158
 
141
- In contrast to many other server configs which require multiple flags, Puma simply uses one URI parameter with the `-b` (or `--bind`) flag:
159
+ Bind Puma to a socket with the `-b` (or `--bind`) flag:
142
160
 
143
161
  ```
144
162
  $ puma -b tcp://127.0.0.1:9292
145
163
  ```
146
164
 
147
- Want to use UNIX Sockets instead of TCP (which can provide a 5-10% performance boost)?
165
+ To use a UNIX Socket instead of TCP:
148
166
 
149
167
  ```
150
168
  $ puma -b unix:///var/run/puma.sock
@@ -157,13 +175,14 @@ $ puma -b 'unix:///var/run/puma.sock?umask=0111'
157
175
  ```
158
176
 
159
177
  Need a bit of security? Use SSL sockets:
178
+
160
179
  ```
161
180
  $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
162
181
  ```
163
182
 
164
183
  #### Controlling SSL Cipher Suites
165
184
 
166
- Need to use or avoid specific SSL cipher suites? Use `ssl_cipher_filter` or `ssl_cipher_list` options.
185
+ To use or avoid specific SSL cipher suites, use `ssl_cipher_filter` or `ssl_cipher_list` options.
167
186
 
168
187
  ##### Ruby:
169
188
 
@@ -179,7 +198,7 @@ $ puma -b 'ssl://127.0.0.1:9292?keystore=path_to_keystore&keystore-pass=keystore
179
198
 
180
199
  See https://www.openssl.org/docs/man1.0.2/apps/ciphers.html for cipher filter format and full list of cipher suites.
181
200
 
182
- Don't want to use insecure TLSv1.0 ?
201
+ Disable TLS v1 with the `no_tlsv1` option:
183
202
 
184
203
  ```
185
204
  $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&no_tlsv1=true'
@@ -187,13 +206,13 @@ $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&no_tlsv1=true'
187
206
 
188
207
  ### Control/Status Server
189
208
 
190
- Puma has a built-in status/control app that can be used to query and control Puma itself.
209
+ Puma has a built-in status and control app that can be used to query and control Puma.
191
210
 
192
211
  ```
193
212
  $ puma --control-url tcp://127.0.0.1:9293 --control-token foo
194
213
  ```
195
214
 
196
- Puma will start the control server on localhost port 9293. All requests to the control server will need to include `token=foo` as a query parameter. This allows for simple authentication. Check out [status.rb](https://github.com/puma/puma/blob/master/lib/puma/app/status.rb) to see what the app has available.
215
+ Puma will start the control server on localhost port 9293. All requests to the control server will need to include control token (in this case, `token=foo`) as a query parameter. This allows for simple authentication. Check out [status.rb](https://github.com/puma/puma/blob/master/lib/puma/app/status.rb) to see what the status app has available.
197
216
 
198
217
  You can also interact with the control server via `pumactl`. This command will restart Puma:
199
218
 
@@ -205,13 +224,13 @@ To see a list of `pumactl` options, use `pumactl --help`.
205
224
 
206
225
  ### Configuration File
207
226
 
208
- You can also provide a configuration file which Puma will use with the `-C` (or `--config`) flag:
227
+ You can also provide a configuration file with the `-C` (or `--config`) flag:
209
228
 
210
229
  ```
211
230
  $ puma -C /path/to/config
212
231
  ```
213
232
 
214
- If no configuration file is specified, Puma will look for a configuration file at `config/puma.rb`. If an environment is specified, either via the `-e` and `--environment` flags, or through the `RACK_ENV` environment variable, the default file location will be `config/puma/environment_name.rb`.
233
+ If no configuration file is specified, Puma will look for a configuration file at `config/puma.rb`. If an environment is specified, either via the `-e` and `--environment` flags, or through the `RACK_ENV` environment variable, Puma looks for configuration at `config/puma/<environment_name>.rb`.
215
234
 
216
235
  If you want to prevent Puma from looking for a configuration file in those locations, provide a dash as the argument to the `-C` (or `--config`) flag:
217
236
 
@@ -219,7 +238,7 @@ If you want to prevent Puma from looking for a configuration file in those locat
219
238
  $ puma -C "-"
220
239
  ```
221
240
 
222
- Take the following [sample configuration](https://github.com/puma/puma/blob/master/examples/config.rb) as inspiration or check out [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb) to see all available options.
241
+ Check out [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb) to see all available options.
223
242
 
224
243
  ## Restart
225
244
 
@@ -236,7 +255,7 @@ Puma responds to several signals. A detailed guide to using UNIX signals with Pu
236
255
  Some platforms do not support all Puma features.
237
256
 
238
257
  * **JRuby**, **Windows**: server sockets are not seamless on restart, they must be closed and reopened. These platforms have no way to pass descriptors into a new process that is exposed to Ruby. Also, cluster mode is not supported due to a lack of fork(2).
239
- * **Windows**: daemon mode is not supported due to a lack of fork(2).
258
+ * **Windows**: Cluster mode is not supported due to a lack of fork(2).
240
259
 
241
260
  ## Known Bugs
242
261
 
@@ -278,6 +297,24 @@ $ bundle install
278
297
  $ bundle exec rake
279
298
  ```
280
299
 
300
+ To run a single test file, use the `TEST` environment variable:
301
+
302
+ ```bash
303
+ $ TEST=test/test_binder.rb bundle exec rake test
304
+ ```
305
+
306
+ Or use [`m`](https://github.com/qrush/m):
307
+
308
+ ```
309
+ $ bundle exec m test/test_binder.rb
310
+ ```
311
+
312
+ Which can also be used to run a single test case:
313
+
314
+ ```
315
+ $ bundle exec m test/test_binder.rb:37
316
+ ```
317
+
281
318
  ## License
282
319
 
283
320
  Puma is copyright Evan Phoenix and contributors, licensed under the BSD 3-Clause license. See the included LICENSE file for details.
@@ -142,7 +142,7 @@ VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
142
142
  VALUE obj;
143
143
  SSL_CTX* ctx;
144
144
  SSL* ssl;
145
- int ssl_options;
145
+ int min, ssl_options;
146
146
 
147
147
  ms_conn* conn = engine_alloc(self, &obj);
148
148
 
@@ -168,6 +168,9 @@ VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
168
168
  ID sym_no_tlsv1 = rb_intern("no_tlsv1");
169
169
  VALUE no_tlsv1 = rb_funcall(mini_ssl_ctx, sym_no_tlsv1, 0);
170
170
 
171
+ ID sym_no_tlsv1_1 = rb_intern("no_tlsv1_1");
172
+ VALUE no_tlsv1_1 = rb_funcall(mini_ssl_ctx, sym_no_tlsv1_1, 0);
173
+
171
174
  #ifdef HAVE_TLS_SERVER_METHOD
172
175
  ctx = SSL_CTX_new(TLS_server_method());
173
176
  #else
@@ -183,12 +186,36 @@ VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
183
186
  SSL_CTX_load_verify_locations(ctx, RSTRING_PTR(ca), NULL);
184
187
  }
185
188
 
186
- ssl_options = SSL_OP_CIPHER_SERVER_PREFERENCE | SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_SINGLE_DH_USE | SSL_OP_SINGLE_ECDH_USE | SSL_OP_NO_COMPRESSION;
189
+ ssl_options = SSL_OP_CIPHER_SERVER_PREFERENCE | SSL_OP_SINGLE_ECDH_USE | SSL_OP_NO_COMPRESSION;
187
190
 
188
- if(RTEST(no_tlsv1)) {
191
+ #ifdef HAVE_SSL_CTX_SET_MIN_PROTO_VERSION
192
+ if (RTEST(no_tlsv1_1)) {
193
+ min = TLS1_2_VERSION;
194
+ }
195
+ else if (RTEST(no_tlsv1)) {
196
+ min = TLS1_1_VERSION;
197
+ }
198
+ else {
199
+ min = TLS1_VERSION;
200
+ }
201
+
202
+ SSL_CTX_set_min_proto_version(ctx, min);
203
+
204
+ SSL_CTX_set_options(ctx, ssl_options);
205
+
206
+ #else
207
+ /* As of 1.0.2f, SSL_OP_SINGLE_DH_USE key use is always on */
208
+ ssl_options |= SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_SINGLE_DH_USE;
209
+
210
+ if (RTEST(no_tlsv1)) {
189
211
  ssl_options |= SSL_OP_NO_TLSv1;
190
212
  }
213
+ if(RTEST(no_tlsv1_1)) {
214
+ ssl_options |= SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1;
215
+ }
191
216
  SSL_CTX_set_options(ctx, ssl_options);
217
+ #endif
218
+
192
219
  SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF);
193
220
 
194
221
  if (!NIL_P(ssl_cipher_filter)) {
@@ -458,14 +485,35 @@ void Init_mini_ssl(VALUE puma) {
458
485
  // OpenSSL Build / Runtime/Load versions
459
486
 
460
487
  /* Version of OpenSSL that Puma was compiled with */
461
- rb_define_const(mod, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT));
488
+ rb_define_const(mod, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT));
462
489
 
463
490
  #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
464
- /* Version of OpenSSL that Puma loaded with */
465
- rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(OpenSSL_version(OPENSSL_VERSION)));
491
+ /* Version of OpenSSL that Puma loaded with */
492
+ rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(OpenSSL_version(OPENSSL_VERSION)));
466
493
  #else
467
- rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION)));
494
+ rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION)));
468
495
  #endif
496
+
497
+ #if defined(OPENSSL_NO_SSL3) || defined(OPENSSL_NO_SSL3_METHOD)
498
+ /* True if SSL3 is not available */
499
+ rb_define_const(mod, "OPENSSL_NO_SSL3", Qtrue);
500
+ #else
501
+ rb_define_const(mod, "OPENSSL_NO_SSL3", Qfalse);
502
+ #endif
503
+
504
+ #if defined(OPENSSL_NO_TLS1) || defined(OPENSSL_NO_TLS1_METHOD)
505
+ /* True if TLS1 is not available */
506
+ rb_define_const(mod, "OPENSSL_NO_TLS1", Qtrue);
507
+ #else
508
+ rb_define_const(mod, "OPENSSL_NO_TLS1", Qfalse);
509
+ #endif
510
+
511
+ #if defined(OPENSSL_NO_TLS1_1) || defined(OPENSSL_NO_TLS1_1_METHOD)
512
+ /* True if TLS1_1 is not available */
513
+ rb_define_const(mod, "OPENSSL_NO_TLS1_1", Qtrue);
514
+ #else
515
+ rb_define_const(mod, "OPENSSL_NO_TLS1_1", Qfalse);
516
+ #endif
469
517
 
470
518
  rb_define_singleton_method(mod, "check", noop, 0);
471
519
 
@@ -166,6 +166,10 @@ public class MiniSSL extends RubyObject {
166
166
  protocols = new String[] { "TLSv1", "TLSv1.1", "TLSv1.2" };
167
167
  }
168
168
 
169
+ if(miniSSLContext.callMethod(threadContext, "no_tlsv1_1").isTrue()) {
170
+ protocols = new String[] { "TLSv1.2" };
171
+ }
172
+
169
173
  engine.setEnabledProtocols(protocols);
170
174
  engine.setUseClientMode(false);
171
175
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Standard libraries
2
4
  require 'socket'
3
5
  require 'tempfile'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'openssl'
2
4
 
3
5
  module OpenSSL
@@ -1,7 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'json'
2
4
 
3
5
  module Puma
4
6
  module App
7
+ # Check out {#call}'s source code to see what actions this web application
8
+ # can respond to.
5
9
  class Status
6
10
  def initialize(cli)
7
11
  @cli = cli
@@ -195,6 +195,7 @@ module Puma
195
195
  end
196
196
 
197
197
  ctx.no_tlsv1 = true if params['no_tlsv1'] == 'true'
198
+ ctx.no_tlsv1_1 = true if params['no_tlsv1_1'] == 'true'
198
199
 
199
200
  if params['verify_mode']
200
201
  ctx.verify_mode = case params['verify_mode']
@@ -68,6 +68,8 @@ module Puma
68
68
  @remote_addr_header = nil
69
69
 
70
70
  @body_remain = 0
71
+
72
+ @in_last_chunk = false
71
73
  end
72
74
 
73
75
  attr_reader :env, :to_io, :body, :io, :timeout_at, :ready, :hijacked,
@@ -108,6 +110,7 @@ module Puma
108
110
  @ready = false
109
111
  @body_remain = 0
110
112
  @peerip = nil
113
+ @in_last_chunk = false
111
114
 
112
115
  if @buffer
113
116
  @parsed_bytes = @parser.execute(@env, @buffer, @parsed_bytes)
@@ -166,7 +169,7 @@ module Puma
166
169
  chunk = chunk[@partial_part_left..-1]
167
170
  @partial_part_left = 0
168
171
  else
169
- @body << chunk
172
+ @body << chunk if @partial_part_left > 2 # don't include the last \r\n
170
173
  @partial_part_left -= chunk.size
171
174
  return false
172
175
  end
@@ -184,12 +187,20 @@ module Puma
184
187
  if line.end_with?("\r\n")
185
188
  len = line.strip.to_i(16)
186
189
  if len == 0
190
+ @in_last_chunk = true
187
191
  @body.rewind
188
192
  rest = io.read
189
- rest = rest[2..-1] if rest.start_with?("\r\n")
190
- @buffer = rest.empty? ? nil : rest
191
- set_ready
192
- return true
193
+ last_crlf_size = "\r\n".bytesize
194
+ if rest.bytesize < last_crlf_size
195
+ @buffer = nil
196
+ @partial_part_left = last_crlf_size - rest.bytesize
197
+ return false
198
+ else
199
+ @buffer = rest[last_crlf_size..-1]
200
+ @buffer = nil if @buffer.empty?
201
+ set_ready
202
+ return true
203
+ end
193
204
  end
194
205
 
195
206
  len += 2
@@ -219,7 +230,12 @@ module Puma
219
230
  end
220
231
  end
221
232
 
222
- return false
233
+ if @in_last_chunk
234
+ set_ready
235
+ true
236
+ else
237
+ false
238
+ end
223
239
  end
224
240
 
225
241
  def read_chunked_body