puma 4.0.1 → 4.1.0

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: 2da4583ff5ef681c3c08be5b56e1bcf2134d34ddf226f066aecc288a8bf197b5
4
- data.tar.gz: '0963edfc828d163f4c7afeee080ff6264171db93416a423b8585fe20f532e7c1'
3
+ metadata.gz: 4564625669c77dfcd7e4096c40f8b24cb3b7b5a938b97309bbb193566ae0869e
4
+ data.tar.gz: 88ae06dc5193587a114ef4f6cec79ad8001333ef9b3fff5c839fd3eea75cf746
5
5
  SHA512:
6
- metadata.gz: 6fcb34a36a1ab1a24c2f2ce859fcb99aa99a7fcdddfa6ab034e1af70fe02b6d44158b8fccb5e3d41c90fefcd80f835aa62e7c6121c428f01f8816abc39d8a3c1
7
- data.tar.gz: 147d74c560432cbaaed701dd815287e4e71241468c6222a6e6186a63e2c39aaeed4615287f5cd3bb373be5195251b17fe98c945c15d73821c9d41bbbc8309a7d
6
+ metadata.gz: ec7c5afdb5cb46e8827ad83c189240e426efab3aaf7b4ac9ef5b2d7977203a30495dd082c08b96299b6c050022da57af28065dfe37f5271e50138ab34e81512f
7
+ data.tar.gz: 81728699a0f8c0c135f72bd03b6fbb76c405f7bcc138a2f918a4abb6978334528e0e004851fa58da254e6c6abb074cc35401835d61d2a3b2e5d9f2134fd10dff
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