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 +4 -4
- data/History.md +28 -0
- data/README.md +63 -26
- data/ext/puma_http11/mini_ssl.c +55 -7
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +4 -0
- data/lib/puma.rb +2 -0
- data/lib/puma/accept_nonblock.rb +2 -0
- data/lib/puma/app/status.rb +4 -0
- data/lib/puma/binder.rb +1 -0
- data/lib/puma/client.rb +22 -6
- data/lib/puma/cluster.rb +9 -6
- data/lib/puma/configuration.rb +2 -2
- data/lib/puma/const.rb +5 -2
- data/lib/puma/control_cli.rb +0 -2
- data/lib/puma/dsl.rb +244 -80
- data/lib/puma/events.rb +6 -3
- data/lib/puma/launcher.rb +3 -1
- data/lib/puma/minissl.rb +25 -19
- data/lib/puma/plugin/tmp_restart.rb +2 -0
- data/lib/puma/rack/builder.rb +2 -0
- data/lib/puma/rack/urlmap.rb +2 -0
- data/lib/puma/rack_default.rb +2 -0
- data/lib/puma/reactor.rb +1 -1
- data/lib/puma/runner.rb +1 -0
- data/lib/puma/server.rb +19 -12
- data/lib/puma/single.rb +1 -1
- data/lib/rack/handler/puma.rb +3 -1
- data/tools/jungle/init.d/puma +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4564625669c77dfcd7e4096c40f8b24cb3b7b5a938b97309bbb193566ae0869e
|
4
|
+
data.tar.gz: 88ae06dc5193587a114ef4f6cec79ad8001333ef9b3fff5c839fd3eea75cf746
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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
|
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
|
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,
|
36
|
+
Puma is the default server for Rails, included in the generated Gemfile.
|
35
37
|
|
36
|
-
|
38
|
+
Start your server with the `rails` command:
|
37
39
|
|
38
40
|
```
|
39
|
-
$ rails
|
41
|
+
$ rails server
|
40
42
|
```
|
41
43
|
|
42
|
-
Many configuration options are not available when using `rails
|
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
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
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,
|
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
|
-
|
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**:
|
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.
|
data/ext/puma_http11/mini_ssl.c
CHANGED
@@ -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
|
189
|
+
ssl_options = SSL_OP_CIPHER_SERVER_PREFERENCE | SSL_OP_SINGLE_ECDH_USE | SSL_OP_NO_COMPRESSION;
|
187
190
|
|
188
|
-
|
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
|
-
|
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
|
-
|
465
|
-
|
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
|
-
|
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
|
|
data/lib/puma.rb
CHANGED
data/lib/puma/accept_nonblock.rb
CHANGED
data/lib/puma/app/status.rb
CHANGED
data/lib/puma/binder.rb
CHANGED
data/lib/puma/client.rb
CHANGED
@@ -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
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
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
|
-
|
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
|