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 +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/puma_http11.jar +0 -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
data/lib/puma/events.rb
CHANGED
@@ -29,8 +29,8 @@ module Puma
|
|
29
29
|
#
|
30
30
|
def initialize(stdout, stderr)
|
31
31
|
@formatter = DefaultFormatter.new
|
32
|
-
@stdout = stdout
|
33
|
-
@stderr = stderr
|
32
|
+
@stdout = stdout.dup
|
33
|
+
@stderr = stderr.dup
|
34
34
|
|
35
35
|
@stdout.sync = true
|
36
36
|
@stderr.sync = true
|
@@ -93,7 +93,10 @@ module Puma
|
|
93
93
|
# parsing exception.
|
94
94
|
#
|
95
95
|
def parse_error(server, env, error)
|
96
|
-
@stderr.puts "#{Time.now}: HTTP parse error, malformed request
|
96
|
+
@stderr.puts "#{Time.now}: HTTP parse error, malformed request " \
|
97
|
+
"(#{env[HTTP_X_FORWARDED_FOR] || env[REMOTE_ADDR]}#{env[REQUEST_PATH]}): " \
|
98
|
+
"#{error.inspect}" \
|
99
|
+
"\n---\n"
|
97
100
|
end
|
98
101
|
|
99
102
|
# An SSL error has occurred.
|
data/lib/puma/launcher.rb
CHANGED
@@ -63,6 +63,9 @@ module Puma
|
|
63
63
|
@options = @config.options
|
64
64
|
@config.clamp
|
65
65
|
|
66
|
+
@events.formatter = Events::PidFormatter.new if clustered?
|
67
|
+
@events.formatter = options[:log_formatter] if @options[:log_formatter]
|
68
|
+
|
66
69
|
generate_restart_data
|
67
70
|
|
68
71
|
if clustered? && !Process.respond_to?(:fork)
|
@@ -81,7 +84,6 @@ module Puma
|
|
81
84
|
set_rack_environment
|
82
85
|
|
83
86
|
if clustered?
|
84
|
-
@events.formatter = Events::PidFormatter.new
|
85
87
|
@options[:logger] = @events
|
86
88
|
|
87
89
|
@runner = Cluster.new(self, @events)
|
data/lib/puma/minissl.rb
CHANGED
@@ -54,22 +54,21 @@ module Puma
|
|
54
54
|
output = engine_read_all
|
55
55
|
return output if output
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end while true
|
57
|
+
data = @socket.read_nonblock(size, exception: false)
|
58
|
+
if data == :wait_readable || data == :wait_writable
|
59
|
+
# It would make more sense to let @socket.read_nonblock raise
|
60
|
+
# EAGAIN if necessary but it seems like it'll misbehave on Windows.
|
61
|
+
# I don't have a Windows machine to debug this so I can't explain
|
62
|
+
# exactly whats happening in that OS. Please let me know if you
|
63
|
+
# find out!
|
64
|
+
#
|
65
|
+
# In the meantime, we can emulate the correct behavior by
|
66
|
+
# capturing :wait_readable & :wait_writable and raising EAGAIN
|
67
|
+
# ourselves.
|
68
|
+
raise IO::EAGAINWaitReadable
|
69
|
+
elsif data.nil?
|
70
|
+
return nil
|
71
|
+
end
|
73
72
|
|
74
73
|
@engine.inject(data)
|
75
74
|
output = engine_read_all
|
@@ -177,10 +176,11 @@ module Puma
|
|
177
176
|
|
178
177
|
class Context
|
179
178
|
attr_accessor :verify_mode
|
180
|
-
attr_reader :no_tlsv1
|
179
|
+
attr_reader :no_tlsv1, :no_tlsv1_1
|
181
180
|
|
182
181
|
def initialize
|
183
|
-
@no_tlsv1
|
182
|
+
@no_tlsv1 = false
|
183
|
+
@no_tlsv1_1 = false
|
184
184
|
end
|
185
185
|
|
186
186
|
if defined?(JRUBY_VERSION)
|
@@ -220,18 +220,24 @@ module Puma
|
|
220
220
|
@ca = ca
|
221
221
|
end
|
222
222
|
|
223
|
-
|
224
223
|
def check
|
225
224
|
raise "Key not configured" unless @key
|
226
225
|
raise "Cert not configured" unless @cert
|
227
226
|
end
|
228
227
|
end
|
229
228
|
|
229
|
+
# disables TLSv1
|
230
230
|
def no_tlsv1=(tlsv1)
|
231
231
|
raise ArgumentError, "Invalid value of no_tlsv1" unless ['true', 'false', true, false].include?(tlsv1)
|
232
232
|
@no_tlsv1 = tlsv1
|
233
233
|
end
|
234
234
|
|
235
|
+
# disables TLSv1 and TLSv1.1. Overrides `#no_tlsv1=`
|
236
|
+
def no_tlsv1_1=(tlsv1_1)
|
237
|
+
raise ArgumentError, "Invalid value of no_tlsv1" unless ['true', 'false', true, false].include?(tlsv1_1)
|
238
|
+
@no_tlsv1_1 = tlsv1_1
|
239
|
+
end
|
240
|
+
|
235
241
|
end
|
236
242
|
|
237
243
|
VERIFY_NONE = 0
|
data/lib/puma/puma_http11.jar
CHANGED
Binary file
|
data/lib/puma/rack/builder.rb
CHANGED
data/lib/puma/rack/urlmap.rb
CHANGED
data/lib/puma/rack_default.rb
CHANGED
data/lib/puma/reactor.rb
CHANGED
@@ -23,7 +23,7 @@ module Puma
|
|
23
23
|
# A connection comes into a `Puma::Server` instance, it is then passed to a `Puma::Reactor` instance,
|
24
24
|
# which stores it in an array and waits for any of the connections to be ready for reading.
|
25
25
|
#
|
26
|
-
# The waiting/wake up is performed with nio4r, which will use the
|
26
|
+
# The waiting/wake up is performed with nio4r, which will use the appropriate backend (libev, Java NIO or
|
27
27
|
# just plain IO#select). The call to `NIO::Selector#select` will "wake up" and
|
28
28
|
# return the references to any objects that caused it to "wake". The reactor
|
29
29
|
# then loops through each of these request objects, and sees if they're complete. If they
|
data/lib/puma/runner.rb
CHANGED
data/lib/puma/server.rb
CHANGED
@@ -588,8 +588,11 @@ module Puma
|
|
588
588
|
end
|
589
589
|
|
590
590
|
def default_server_port(env)
|
591
|
-
|
592
|
-
|
591
|
+
if ['on', HTTPS].include?(env[HTTPS_KEY]) || env[HTTP_X_FORWARDED_PROTO].to_s[0...5] == HTTPS || env[HTTP_X_FORWARDED_SCHEME] == HTTPS || env[HTTP_X_FORWARDED_SSL] == "on"
|
592
|
+
PORT_443
|
593
|
+
else
|
594
|
+
PORT_80
|
595
|
+
end
|
593
596
|
end
|
594
597
|
|
595
598
|
# Takes the request +req+, invokes the Rack application to construct
|
@@ -627,23 +630,27 @@ module Puma
|
|
627
630
|
head = env[REQUEST_METHOD] == HEAD
|
628
631
|
|
629
632
|
env[RACK_INPUT] = body
|
630
|
-
env[RACK_URL_SCHEME] =
|
633
|
+
env[RACK_URL_SCHEME] = default_server_port(env) == PORT_443 ? HTTPS : HTTP
|
631
634
|
|
632
635
|
if @early_hints
|
633
636
|
env[EARLY_HINTS] = lambda { |headers|
|
634
|
-
|
637
|
+
begin
|
638
|
+
fast_write client, "HTTP/1.1 103 Early Hints\r\n".freeze
|
635
639
|
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
+
headers.each_pair do |k, vs|
|
641
|
+
if vs.respond_to?(:to_s) && !vs.to_s.empty?
|
642
|
+
vs.to_s.split(NEWLINE).each do |v|
|
643
|
+
fast_write client, "#{k}: #{v}\r\n"
|
644
|
+
end
|
645
|
+
else
|
646
|
+
fast_write client, "#{k}: #{vs}\r\n"
|
640
647
|
end
|
641
|
-
else
|
642
|
-
fast_write client, "#{k}: #{vs}\r\n"
|
643
648
|
end
|
644
|
-
end
|
645
649
|
|
646
|
-
|
650
|
+
fast_write client, "\r\n".freeze
|
651
|
+
rescue ConnectionError
|
652
|
+
# noop, if we lost the socket we just won't send the early hints
|
653
|
+
end
|
647
654
|
}
|
648
655
|
end
|
649
656
|
|
data/lib/puma/single.rb
CHANGED
@@ -18,7 +18,7 @@ module Puma
|
|
18
18
|
r = @server.running || 0
|
19
19
|
t = @server.pool_capacity || 0
|
20
20
|
m = @server.max_threads || 0
|
21
|
-
%Q!{ "backlog": #{b}, "running": #{r}, "pool_capacity": #{t}, "max_threads": #{m} }!
|
21
|
+
%Q!{ "started_at": "#{@started_at.utc.iso8601}", "backlog": #{b}, "running": #{r}, "pool_capacity": #{t}, "max_threads": #{m} }!
|
22
22
|
end
|
23
23
|
|
24
24
|
def restart
|
data/lib/rack/handler/puma.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rack/handler'
|
2
4
|
|
3
5
|
module Rack
|
@@ -86,7 +88,7 @@ module Rack
|
|
86
88
|
"Verbose" => "Don't report each request (default: false)"
|
87
89
|
}
|
88
90
|
end
|
89
|
-
|
91
|
+
|
90
92
|
def self.set_host_port_to_config(host, port, config)
|
91
93
|
config.clear_binds! if host || port
|
92
94
|
|
data/tools/jungle/init.d/puma
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Evan Phoenix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|