puma 8.1.3-java → 8.2.0.pre1-java
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.
- checksums.yaml +4 -4
- data/History.md +120 -0
- data/README.md +4 -3
- data/docs/GLOSSARY.md +160 -0
- data/docs/architecture.md +41 -42
- data/docs/binding.md +3 -0
- data/docs/cluster_mode.md +21 -21
- data/docs/control_server.md +4 -4
- data/docs/deployment/nginx.md +2 -0
- data/docs/deployment/systemd.md +15 -0
- data/docs/puma_support.md +12 -0
- data/docs/restart.md +2 -2
- data/docs/signals.md +3 -3
- data/docs/ssl.md +65 -0
- data/docs/upgrading/5.0-Upgrade.md +1 -1
- data/docs/upgrading/6.0-Upgrade.md +1 -1
- data/docs/upgrading/7.0-Upgrade.md +1 -1
- data/docs/upgrading/8.0-Upgrade.md +1 -1
- data/lib/puma/app/status.rb +22 -7
- data/lib/puma/binder.rb +0 -1
- data/lib/puma/cli.rb +1 -3
- data/lib/puma/client.rb +133 -57
- data/lib/puma/client_env.rb +9 -11
- data/lib/puma/cluster/worker.rb +0 -6
- data/lib/puma/cluster.rb +3 -14
- data/lib/puma/cluster_accept_loop_delay.rb +18 -7
- data/lib/puma/commonlogger.rb +3 -4
- data/lib/puma/configuration.rb +4 -1
- data/lib/puma/const.rb +5 -5
- data/lib/puma/control_cli.rb +5 -7
- data/lib/puma/detect.rb +1 -1
- data/lib/puma/dsl.rb +70 -14
- data/lib/puma/http_parser_error.rb +8 -0
- data/lib/puma/launcher/bundle_pruner.rb +3 -21
- data/lib/puma/launcher.rb +55 -25
- data/lib/puma/minissl/context_builder.rb +3 -2
- data/lib/puma/minissl.rb +12 -16
- data/lib/puma/plugin/systemd.rb +69 -3
- data/lib/puma/puma_http11.jar +0 -0
- data/lib/puma/rack/urlmap.rb +2 -2
- data/lib/puma/reactor.rb +138 -25
- data/lib/puma/response.rb +65 -38
- data/lib/puma/runner.rb +4 -1
- data/lib/puma/sd_notify.rb +21 -0
- data/lib/puma/server.rb +14 -14
- data/lib/puma/server_plugin_control.rb +2 -1
- data/lib/puma/single.rb +0 -1
- data/lib/puma/thread_pool.rb +87 -14
- data/lib/puma/util.rb +5 -16
- data/lib/puma.rb +22 -5
- data/lib/rack/handler/puma.rb +1 -5
- metadata +5 -2
data/lib/puma/client_env.rb
CHANGED
|
@@ -13,25 +13,23 @@ module Puma
|
|
|
13
13
|
include Puma::Const
|
|
14
14
|
|
|
15
15
|
def validate_env
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
unless @env.key? HTTP_HOST
|
|
16
|
+
if @env[REQUEST_URI] == '*' && @env[REQUEST_METHOD] != 'OPTIONS'
|
|
19
17
|
@error_status_code = 400
|
|
20
18
|
@env[HTTP_CONNECTION] = CLOSE
|
|
21
|
-
raise HttpParserError, "
|
|
19
|
+
raise HttpParserError, "Invalid request-target '*' for #{@env[REQUEST_METHOD]}"
|
|
22
20
|
end
|
|
23
21
|
|
|
24
|
-
if @env[
|
|
22
|
+
return if @env[SERVER_PROTOCOL] == HTTP_10
|
|
23
|
+
|
|
24
|
+
unless @env.key?(HTTP_HOST)
|
|
25
25
|
@error_status_code = 400
|
|
26
26
|
@env[HTTP_CONNECTION] = CLOSE
|
|
27
|
-
raise HttpParserError, "
|
|
27
|
+
raise HttpParserError, "Missing Host header"
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
# Given a Hash
|
|
31
|
+
# Given a Hash +@env+ for the request, add
|
|
32
32
|
# and fixup keys to comply with Rack's env guidelines.
|
|
33
|
-
# @param env [Hash] see Puma::Client#env, from request
|
|
34
|
-
# @param client [Puma::Client] only needed for Client#peerip
|
|
35
33
|
#
|
|
36
34
|
def normalize_env
|
|
37
35
|
if host = @env[HTTP_HOST]
|
|
@@ -110,7 +108,8 @@ module Puma
|
|
|
110
108
|
@env[HIJACK_P] = true
|
|
111
109
|
@env[HIJACK] = method(:full_hijack).to_proc
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
input = @body.nil? || @body.equal?(Client::EmptyBody) ? @empty_rack_input : @body
|
|
112
|
+
@env[RACK_INPUT] = input if input
|
|
114
113
|
@env[RACK_URL_SCHEME] ||= default_server_port == PORT_443 ? HTTPS : HTTP
|
|
115
114
|
end
|
|
116
115
|
|
|
@@ -126,7 +125,6 @@ module Puma
|
|
|
126
125
|
# ignore the `,` version. This prevents clobbering headers managed by
|
|
127
126
|
# proxies but not by clients (Like X-Forwarded-For).
|
|
128
127
|
#
|
|
129
|
-
# @param env [Hash] see Puma::Client#env, from request, modifies in place
|
|
130
128
|
# @version 5.0.3
|
|
131
129
|
#
|
|
132
130
|
def req_env_post_parse
|
data/lib/puma/cluster/worker.rb
CHANGED
|
@@ -244,12 +244,6 @@ module Puma
|
|
|
244
244
|
new_worker.run
|
|
245
245
|
end
|
|
246
246
|
|
|
247
|
-
if !pid
|
|
248
|
-
log "! Complete inability to spawn new workers detected"
|
|
249
|
-
log "! Seppuku is the only choice."
|
|
250
|
-
exit! 1
|
|
251
|
-
end
|
|
252
|
-
|
|
253
247
|
@worker_pids << pid
|
|
254
248
|
@config.run_hooks(:after_worker_fork, idx, @log_writer, @hook_data)
|
|
255
249
|
pid
|
data/lib/puma/cluster.rb
CHANGED
|
@@ -25,7 +25,6 @@ module Puma
|
|
|
25
25
|
@workers = []
|
|
26
26
|
@next_check = Time.now
|
|
27
27
|
|
|
28
|
-
@worker_max = [] # keeps track of 'max' stat values
|
|
29
28
|
@pending_phased_restart = false
|
|
30
29
|
@promoted_mold = nil
|
|
31
30
|
@mold = nil
|
|
@@ -115,11 +114,6 @@ module Puma
|
|
|
115
114
|
@config.run_hooks(:before_worker_fork, idx, @log_writer)
|
|
116
115
|
|
|
117
116
|
pid = fork { worker(idx, master) }
|
|
118
|
-
if !pid
|
|
119
|
-
log "! Complete inability to spawn new workers detected"
|
|
120
|
-
log "! Seppuku is the only choice."
|
|
121
|
-
exit! 1
|
|
122
|
-
end
|
|
123
117
|
|
|
124
118
|
@config.run_hooks(:after_worker_fork, idx, @log_writer)
|
|
125
119
|
pid
|
|
@@ -247,7 +241,6 @@ module Puma
|
|
|
247
241
|
end
|
|
248
242
|
|
|
249
243
|
def restart
|
|
250
|
-
@restart = true
|
|
251
244
|
stop
|
|
252
245
|
end
|
|
253
246
|
|
|
@@ -425,13 +418,9 @@ module Puma
|
|
|
425
418
|
|
|
426
419
|
if after.size > before.size
|
|
427
420
|
threads = (after - before)
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
log "! #{t.inspect} - #{t.backtrace ? t.backtrace.first : ''}"
|
|
432
|
-
end
|
|
433
|
-
else
|
|
434
|
-
log "! WARNING: Detected #{after.size-before.size} Thread(s) started in app boot"
|
|
421
|
+
log "! WARNING: Detected #{after.size-before.size} Thread(s) started in app boot:"
|
|
422
|
+
threads.each do |t|
|
|
423
|
+
log "! #{t.inspect} - #{t.backtrace ? t.backtrace.first : ''}"
|
|
435
424
|
end
|
|
436
425
|
end
|
|
437
426
|
else
|
|
@@ -46,9 +46,11 @@ module Puma
|
|
|
46
46
|
#
|
|
47
47
|
# For now, both goals are framed as "load balancing" across workers (processes) and achieved through
|
|
48
48
|
# the same mechanism of sleeping longer to delay busier workers. Rather than the prior Puma 6.x
|
|
49
|
-
# and earlier behavior of using a binary on/off sleep value, we
|
|
50
|
-
#
|
|
51
|
-
#
|
|
49
|
+
# and earlier behavior of using a binary on/off sleep value, we scale the delay across two regimes:
|
|
50
|
+
# below thread saturation (`u <= 1.0`), a concave square-root ramp (`Math.sqrt(u)`) applies earlier
|
|
51
|
+
# tie-breaking backpressure as threads become busy (especially on CPU-bound workloads sharing a GVL);
|
|
52
|
+
# above saturation (`1.0 < u < overload_multiplier`), a linear overload ramp scales smoothly to
|
|
53
|
+
# `max_delay` at `max_threads * overload_multiplier` without over-sleeping during high-concurrency bursts.
|
|
52
54
|
#
|
|
53
55
|
# Private: API may change unexpectedly
|
|
54
56
|
class ClusterAcceptLoopDelay
|
|
@@ -66,6 +68,8 @@ module Puma
|
|
|
66
68
|
|
|
67
69
|
# Reach maximum delay when `max_threads * overload_multiplier` is reached in the system
|
|
68
70
|
@overload_multiplier = 25.0
|
|
71
|
+
@knee_base = 1.25 / @overload_multiplier
|
|
72
|
+
@overload_slope = (1.0 - @knee_base) / (@overload_multiplier - 1.0)
|
|
69
73
|
end
|
|
70
74
|
|
|
71
75
|
def on?
|
|
@@ -75,7 +79,7 @@ module Puma
|
|
|
75
79
|
# We want the extreme values of this delay to be known (minimum and maximum) as well as
|
|
76
80
|
# a predictable curve between the two. i.e. no step functions or hard cliffs.
|
|
77
81
|
#
|
|
78
|
-
# Return value is always
|
|
82
|
+
# Return value is always a Float. Returns 0.0 if there should be no delay.
|
|
79
83
|
def calculate(
|
|
80
84
|
# Number of threads working right now, plus number of requests in the todo list
|
|
81
85
|
busy_threads_plus_todo:,
|
|
@@ -83,9 +87,16 @@ module Puma
|
|
|
83
87
|
# if the pool needs to be reaped. The busy thread plus todo count may go over this value by a large amount.
|
|
84
88
|
max_threads:
|
|
85
89
|
)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
return 0.0 if @max_delay == 0 || busy_threads_plus_todo <= 0
|
|
91
|
+
|
|
92
|
+
u = busy_threads_plus_todo.to_f / max_threads.to_f
|
|
93
|
+
if u <= 1.0
|
|
94
|
+
return @max_delay * @knee_base * Math.sqrt(u)
|
|
95
|
+
elsif u >= @overload_multiplier
|
|
96
|
+
return @max_delay
|
|
97
|
+
else
|
|
98
|
+
return @max_delay * (@knee_base + @overload_slope * (u - 1.0))
|
|
99
|
+
end
|
|
89
100
|
end
|
|
90
101
|
end
|
|
91
102
|
end
|
data/lib/puma/commonlogger.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Puma
|
|
4
|
-
#
|
|
4
|
+
# Puma::CommonLogger forwards every request to the given +app+, and
|
|
5
5
|
# logs a line in the
|
|
6
6
|
# {Apache common log format}[https://httpd.apache.org/docs/2.4/logs.html#common]
|
|
7
7
|
# to the +logger+.
|
|
@@ -20,7 +20,6 @@ module Puma
|
|
|
20
20
|
#
|
|
21
21
|
# lilith.local - - [07/Aug/2006 23:58:02 -0400] "GET / HTTP/1.1" 500 -
|
|
22
22
|
#
|
|
23
|
-
# %{%s - %s [%s] "%s %s%s %s" %d %s\n} %
|
|
24
23
|
FORMAT = %{%s - %s [%s] "%s %s%s %s" %d %s %0.4f\n}
|
|
25
24
|
|
|
26
25
|
HIJACK_FORMAT = %{%s - %s [%s] "%s %s%s %s" HIJACKED -1 %0.4f\n}
|
|
@@ -49,7 +48,7 @@ module Puma
|
|
|
49
48
|
|
|
50
49
|
# If we've been hijacked, then output a special line
|
|
51
50
|
if env['rack.hijack_io']
|
|
52
|
-
log_hijacking(env,
|
|
51
|
+
log_hijacking(env, began_at)
|
|
53
52
|
else
|
|
54
53
|
ary = env['rack.after_reply']
|
|
55
54
|
ary << lambda { log(env, status, header, began_at) }
|
|
@@ -60,7 +59,7 @@ module Puma
|
|
|
60
59
|
|
|
61
60
|
private
|
|
62
61
|
|
|
63
|
-
def log_hijacking(env,
|
|
62
|
+
def log_hijacking(env, began_at)
|
|
64
63
|
now = Time.now
|
|
65
64
|
|
|
66
65
|
msg = HIJACK_FORMAT % [
|
data/lib/puma/configuration.rb
CHANGED
|
@@ -145,10 +145,12 @@ module Puma
|
|
|
145
145
|
first_data_timeout: 30,
|
|
146
146
|
force_shutdown_after: -1,
|
|
147
147
|
http_content_length_limit: nil,
|
|
148
|
+
http_parser: nil,
|
|
148
149
|
shutdown_body_timeout: 25,
|
|
149
150
|
# Number of seconds to wait until the next request before shutting down.
|
|
150
151
|
idle_timeout: nil,
|
|
151
152
|
io_selector_backend: :auto,
|
|
153
|
+
date_header: true,
|
|
152
154
|
log_requests: false,
|
|
153
155
|
logger: STDOUT,
|
|
154
156
|
# Limits how many requests a keep alive connection can make.
|
|
@@ -160,6 +162,7 @@ module Puma
|
|
|
160
162
|
min_threads: 0,
|
|
161
163
|
mode: :http,
|
|
162
164
|
mutate_stdout_and_stderr_to_sync_on_write: true,
|
|
165
|
+
nil_rack_input_on_empty_body: false,
|
|
163
166
|
out_of_band: [],
|
|
164
167
|
# Number of seconds for another request within a persistent session.
|
|
165
168
|
persistent_timeout: 65, # PUMA_PERSISTENT_TIMEOUT
|
|
@@ -223,7 +226,7 @@ module Puma
|
|
|
223
226
|
def initialize_copy(other)
|
|
224
227
|
@conf = nil
|
|
225
228
|
@cli_options = nil
|
|
226
|
-
@_options
|
|
229
|
+
@_options = @_options.dup
|
|
227
230
|
end
|
|
228
231
|
|
|
229
232
|
def flatten
|
data/lib/puma/const.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#encoding: utf-8
|
|
2
1
|
# frozen_string_literal: true
|
|
3
2
|
|
|
4
3
|
module Puma
|
|
@@ -100,8 +99,8 @@ module Puma
|
|
|
100
99
|
# too taxing on performance.
|
|
101
100
|
module Const
|
|
102
101
|
|
|
103
|
-
PUMA_VERSION = VERSION = "8.
|
|
104
|
-
CODE_NAME = "
|
|
102
|
+
PUMA_VERSION = VERSION = "8.2.0.pre1"
|
|
103
|
+
CODE_NAME = "Windows 96"
|
|
105
104
|
|
|
106
105
|
PUMA_SERVER_STRING = ["puma", PUMA_VERSION, CODE_NAME].join(" ").freeze
|
|
107
106
|
|
|
@@ -125,7 +124,7 @@ module Puma
|
|
|
125
124
|
ERROR_RESPONSE = {
|
|
126
125
|
# Indicate that we couldn't parse the request
|
|
127
126
|
400 => "HTTP/1.1 400 Bad Request\r\n\r\n",
|
|
128
|
-
# The standard empty 404 response for bad requests.
|
|
127
|
+
# The standard empty 404 response for bad requests.
|
|
129
128
|
404 => "HTTP/1.1 404 Not Found\r\nconnection: close\r\n\r\n",
|
|
130
129
|
# The standard empty 408 response for requests that timed out.
|
|
131
130
|
408 => "HTTP/1.1 408 Request Timeout\r\nconnection: close\r\n\r\n",
|
|
@@ -199,7 +198,6 @@ module Puma
|
|
|
199
198
|
VERSION-CONTROL
|
|
200
199
|
].freeze
|
|
201
200
|
|
|
202
|
-
# ETag is based on the apache standard of hex mtime-size-inode (inode is 0 on win32)
|
|
203
201
|
LINE_END = "\r\n"
|
|
204
202
|
REMOTE_ADDR = "REMOTE_ADDR"
|
|
205
203
|
HTTP_X_FORWARDED_FOR = "HTTP_X_FORWARDED_FOR"
|
|
@@ -219,6 +217,7 @@ module Puma
|
|
|
219
217
|
UNSPECIFIED_IPV6 = "::"
|
|
220
218
|
|
|
221
219
|
SERVER_PROTOCOL = "SERVER_PROTOCOL"
|
|
220
|
+
HTTP_10 = "HTTP/1.0"
|
|
222
221
|
HTTP_11 = "HTTP/1.1"
|
|
223
222
|
|
|
224
223
|
SERVER_SOFTWARE = "SERVER_SOFTWARE"
|
|
@@ -274,6 +273,7 @@ module Puma
|
|
|
274
273
|
|
|
275
274
|
HIJACK_P = "rack.hijack?"
|
|
276
275
|
HIJACK = "rack.hijack"
|
|
276
|
+
DATE = "date"
|
|
277
277
|
HIJACK_IO = "rack.hijack_io"
|
|
278
278
|
|
|
279
279
|
EARLY_HINTS = "rack.early_hints"
|
data/lib/puma/control_cli.rb
CHANGED
|
@@ -49,10 +49,8 @@ module Puma
|
|
|
49
49
|
@command = nil
|
|
50
50
|
@environment = env['APP_ENV'] || env['RACK_ENV'] || env['RAILS_ENV']
|
|
51
51
|
|
|
52
|
-
@argv = argv.dup
|
|
53
52
|
@stdout = stdout
|
|
54
53
|
@stderr = stderr
|
|
55
|
-
@cli_options = {}
|
|
56
54
|
|
|
57
55
|
opts = OptionParser.new do |o|
|
|
58
56
|
o.banner = "Usage: pumactl (-p PID | -P pidfile | -S status_file | -C url -T token | -F config.rb) (#{CMD_PATH_SIG_MAP.keys.join("|")})"
|
|
@@ -226,14 +224,14 @@ module Puma
|
|
|
226
224
|
raise "Server sent empty response"
|
|
227
225
|
end
|
|
228
226
|
|
|
229
|
-
|
|
227
|
+
_, code, = response.first.split(' ', 3)
|
|
230
228
|
|
|
231
|
-
if
|
|
229
|
+
if code == '403'
|
|
232
230
|
raise 'Unauthorized access to server (wrong auth token)'
|
|
233
|
-
elsif
|
|
231
|
+
elsif code == '404'
|
|
234
232
|
raise "Command error: #{response.last}"
|
|
235
|
-
elsif
|
|
236
|
-
raise "Bad response from server: #{
|
|
233
|
+
elsif code != '200'
|
|
234
|
+
raise "Bad response from server: #{code}"
|
|
237
235
|
end
|
|
238
236
|
|
|
239
237
|
message "Command #{@command} sent success"
|
data/lib/puma/detect.rb
CHANGED
data/lib/puma/dsl.rb
CHANGED
|
@@ -134,7 +134,6 @@ module Puma
|
|
|
134
134
|
|
|
135
135
|
def _load_from(path)
|
|
136
136
|
if path
|
|
137
|
-
@path = path
|
|
138
137
|
instance_eval(File.read(path), path, 1)
|
|
139
138
|
end
|
|
140
139
|
ensure
|
|
@@ -144,7 +143,6 @@ module Puma
|
|
|
144
143
|
def _offer_plugins
|
|
145
144
|
@plugins.each do |o|
|
|
146
145
|
if o.respond_to? :config
|
|
147
|
-
@options.shift
|
|
148
146
|
o.config self
|
|
149
147
|
end
|
|
150
148
|
end
|
|
@@ -219,7 +217,13 @@ module Puma
|
|
|
219
217
|
# @example
|
|
220
218
|
# activate_control_app 'unix:///var/run/pumactl.sock', { no_token: true }
|
|
221
219
|
# @example
|
|
222
|
-
# activate_control_app 'unix:///var/run/pumactl.sock', { no_token: true, data_only: true}
|
|
220
|
+
# activate_control_app 'unix:///var/run/pumactl.sock', { no_token: true, data_only: true }
|
|
221
|
+
# @example
|
|
222
|
+
# activate_control_app 'unix:///var/run/pumactl.sock', { auth_token: '12345', data_token: '67890' }
|
|
223
|
+
# @example
|
|
224
|
+
# activate_control_app 'unix:///var/run/pumactl.sock', { auth_token: '12345', data_token: 'none' }
|
|
225
|
+
# @example
|
|
226
|
+
# activate_control_app 'unix:///var/run/pumactl.sock', { auth_token: '12345', data_token: :none }
|
|
223
227
|
#
|
|
224
228
|
def activate_control_app(url="auto", opts={})
|
|
225
229
|
if url == "auto"
|
|
@@ -243,6 +247,7 @@ module Puma
|
|
|
243
247
|
end
|
|
244
248
|
|
|
245
249
|
@options[:control_auth_token] = auth_token
|
|
250
|
+
@options[:control_data_token] = opts[:data_token] if opts[:data_token]
|
|
246
251
|
@options[:control_url_umask] = opts[:umask] if opts[:umask]
|
|
247
252
|
@options[:control_data_only] = opts[:data_only] if opts[:data_only]
|
|
248
253
|
end
|
|
@@ -336,6 +341,12 @@ module Puma
|
|
|
336
341
|
|
|
337
342
|
# Define how long the TCP socket stays open when no data has been received.
|
|
338
343
|
#
|
|
344
|
+
# This is also the maximum time a client may take to send its request line
|
|
345
|
+
# and headers (and PROXY protocol line, if enabled), even if it keeps
|
|
346
|
+
# sending data. The deadline starts when Puma begins reading each request.
|
|
347
|
+
# While reading the request body, this timeout restarts whenever data is
|
|
348
|
+
# received.
|
|
349
|
+
#
|
|
339
350
|
# The default is 30 seconds.
|
|
340
351
|
#
|
|
341
352
|
# @example
|
|
@@ -1225,7 +1236,6 @@ module Puma
|
|
|
1225
1236
|
#
|
|
1226
1237
|
# @note Cluster mode only.
|
|
1227
1238
|
# @note This is incompatible with +preload_app!+.
|
|
1228
|
-
# @note This is only supported for RubyGems 2.2+.
|
|
1229
1239
|
#
|
|
1230
1240
|
# @example
|
|
1231
1241
|
# prune_bundler
|
|
@@ -1266,7 +1276,7 @@ module Puma
|
|
|
1266
1276
|
# @example
|
|
1267
1277
|
# extra_runtime_dependencies ['puma_worker_killer', 'puma-heroku']
|
|
1268
1278
|
#
|
|
1269
|
-
# @see Puma::Launcher#
|
|
1279
|
+
# @see Puma::Launcher::BundlePruner#extra_runtime_deps_paths
|
|
1270
1280
|
#
|
|
1271
1281
|
def extra_runtime_dependencies(answer = [])
|
|
1272
1282
|
@options[:extra_runtime_dependencies] = Array(answer)
|
|
@@ -1317,7 +1327,7 @@ module Puma
|
|
|
1317
1327
|
# @example
|
|
1318
1328
|
# worker_timeout 60
|
|
1319
1329
|
#
|
|
1320
|
-
# @see Puma::Cluster::
|
|
1330
|
+
# @see Puma::Cluster::WorkerHandle#ping_timeout
|
|
1321
1331
|
#
|
|
1322
1332
|
def worker_timeout(timeout)
|
|
1323
1333
|
timeout = Integer(timeout)
|
|
@@ -1339,7 +1349,7 @@ module Puma
|
|
|
1339
1349
|
# @example
|
|
1340
1350
|
# worker_boot_timeout 60
|
|
1341
1351
|
#
|
|
1342
|
-
# @see Puma::Cluster::
|
|
1352
|
+
# @see Puma::Cluster::WorkerHandle#ping_timeout
|
|
1343
1353
|
#
|
|
1344
1354
|
def worker_boot_timeout(timeout)
|
|
1345
1355
|
@options[:worker_boot_timeout] = Integer(timeout)
|
|
@@ -1354,7 +1364,7 @@ module Puma
|
|
|
1354
1364
|
# @example
|
|
1355
1365
|
# worker_shutdown_timeout 90
|
|
1356
1366
|
#
|
|
1357
|
-
# @see Puma::Cluster::
|
|
1367
|
+
# @see Puma::Cluster::WorkerHandle#term
|
|
1358
1368
|
#
|
|
1359
1369
|
def worker_shutdown_timeout(timeout)
|
|
1360
1370
|
@options[:worker_shutdown_timeout] = Integer(timeout)
|
|
@@ -1388,15 +1398,15 @@ module Puma
|
|
|
1388
1398
|
@options[:worker_culling_strategy] = strategy
|
|
1389
1399
|
end
|
|
1390
1400
|
|
|
1391
|
-
# When `true`, a
|
|
1392
|
-
# incomplete request body hands the client to
|
|
1401
|
+
# When `true`, a thread that receives a client with an
|
|
1402
|
+
# incomplete request body hands the client to the Reactor thread
|
|
1393
1403
|
# and returns to the pool. The Reactor re-enqueues the client
|
|
1394
|
-
# once the body has been received. This frees
|
|
1404
|
+
# once the body has been received. This frees threads from
|
|
1395
1405
|
# blocking on slow client sends and enables HTTP keep-alive. A
|
|
1396
|
-
#
|
|
1406
|
+
# thread must still receive each client first, so this does
|
|
1397
1407
|
# not queue new connections when the pool is saturated.
|
|
1398
1408
|
#
|
|
1399
|
-
# When `false`, no Reactor runs. A
|
|
1409
|
+
# When `false`, no Reactor runs. A thread reads each
|
|
1400
1410
|
# request synchronously and remains occupied for the duration
|
|
1401
1411
|
# of the client's request send, and HTTP keep-alive is
|
|
1402
1412
|
# disabled. Consider running Puma behind a reverse proxy such
|
|
@@ -1448,7 +1458,7 @@ module Puma
|
|
|
1448
1458
|
# @note Interpreters with forking support only.
|
|
1449
1459
|
#
|
|
1450
1460
|
# @see Puma::Server#handle_servers
|
|
1451
|
-
# @see Puma::
|
|
1461
|
+
# @see Puma::ClusterAcceptLoopDelay
|
|
1452
1462
|
#
|
|
1453
1463
|
def wait_for_less_busy_worker(val=0.005)
|
|
1454
1464
|
@options[:wait_for_less_busy_worker] = val.to_f
|
|
@@ -1625,6 +1635,18 @@ module Puma
|
|
|
1625
1635
|
@options[:allow_underscore_headers] = allowed
|
|
1626
1636
|
end
|
|
1627
1637
|
|
|
1638
|
+
# Add a +Date+ response header (RFC 9110 §6.6.1) when the application
|
|
1639
|
+
# does not set one.
|
|
1640
|
+
#
|
|
1641
|
+
# The default is +true+.
|
|
1642
|
+
#
|
|
1643
|
+
# @example
|
|
1644
|
+
# date_header false
|
|
1645
|
+
#
|
|
1646
|
+
def date_header(enabled = true)
|
|
1647
|
+
@options[:date_header] = enabled
|
|
1648
|
+
end
|
|
1649
|
+
|
|
1628
1650
|
# Specify the backend for the IO selector.
|
|
1629
1651
|
#
|
|
1630
1652
|
# Provided values will be passed directly to +NIO::Selector.new+, with the
|
|
@@ -1676,6 +1698,40 @@ module Puma
|
|
|
1676
1698
|
@options[:http_content_length_limit] = limit
|
|
1677
1699
|
end
|
|
1678
1700
|
|
|
1701
|
+
# Leave +rack.input+ unset for requests with no body, as Rack 3.1 allows,
|
|
1702
|
+
# instead of setting it to an empty stream. Apps then need to check for
|
|
1703
|
+
# +nil+ before reading it. Has no effect with Rack before 3.1, which
|
|
1704
|
+
# requires +rack.input+.
|
|
1705
|
+
#
|
|
1706
|
+
# The default is +false+.
|
|
1707
|
+
#
|
|
1708
|
+
# @example
|
|
1709
|
+
# nil_rack_input_on_empty_body
|
|
1710
|
+
#
|
|
1711
|
+
def nil_rack_input_on_empty_body(enabled = true)
|
|
1712
|
+
@options[:nil_rack_input_on_empty_body] = enabled
|
|
1713
|
+
end
|
|
1714
|
+
|
|
1715
|
+
# The class or callable factory used to parse HTTP requests, instead of the
|
|
1716
|
+
# default `Puma::HttpParser` from Puma's `puma_http11` extension.
|
|
1717
|
+
#
|
|
1718
|
+
# Pass a class (instantiated with +new+ per connection), a callable object
|
|
1719
|
+
# responding to +call+, or a block that returns a new parser instance.
|
|
1720
|
+
# The parser instance must follow the same interface as `Puma::HttpParser`.
|
|
1721
|
+
#
|
|
1722
|
+
# The default is +nil+, which uses `Puma::HttpParser`.
|
|
1723
|
+
#
|
|
1724
|
+
# @example With a parser class
|
|
1725
|
+
# require "puma/http1"
|
|
1726
|
+
# http_parser Puma::HTTP1::Parser
|
|
1727
|
+
#
|
|
1728
|
+
# @example With a block factory
|
|
1729
|
+
# http_parser { MyParser.new(max_header_size: 8192) }
|
|
1730
|
+
#
|
|
1731
|
+
def http_parser(parser = nil, &block)
|
|
1732
|
+
@options[:http_parser] = parser || block
|
|
1733
|
+
end
|
|
1734
|
+
|
|
1679
1735
|
# Supported http methods, which will replace `Puma::Const::SUPPORTED_HTTP_METHODS`.
|
|
1680
1736
|
# The value of `:any` will allow all methods, otherwise, the value must be
|
|
1681
1737
|
# an array of strings. Note that methods are all uppercase.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Puma
|
|
4
|
+
# Raised for a request that is not valid HTTP. It is defined here, as well
|
|
5
|
+
# as in the puma_http11 extension, so that a parser set with the
|
|
6
|
+
# `http_parser` option can raise it when the extension is not loaded.
|
|
7
|
+
class HttpParserError < StandardError; end
|
|
8
|
+
end
|
|
@@ -17,8 +17,6 @@ module Puma
|
|
|
17
17
|
return if ENV['PUMA_BUNDLER_PRUNED']
|
|
18
18
|
return unless defined?(Bundler)
|
|
19
19
|
|
|
20
|
-
require_rubygems_min_version!
|
|
21
|
-
|
|
22
20
|
unless puma_wild_path
|
|
23
21
|
log "! Unable to prune Bundler environment, continuing"
|
|
24
22
|
return
|
|
@@ -30,7 +28,7 @@ module Puma
|
|
|
30
28
|
home = ENV['GEM_HOME']
|
|
31
29
|
original_bundle_env = Bundler.original_env.select { |k, v| k.start_with?('BUNDLE_') && v }
|
|
32
30
|
|
|
33
|
-
with_unbundled_env do
|
|
31
|
+
Bundler.with_unbundled_env do
|
|
34
32
|
ENV['GEM_HOME'] = home
|
|
35
33
|
ENV['PUMA_BUNDLER_PRUNED'] = '1'
|
|
36
34
|
original_bundle_env.each { |k, v| ENV[k] = v }
|
|
@@ -43,27 +41,11 @@ module Puma
|
|
|
43
41
|
|
|
44
42
|
private
|
|
45
43
|
|
|
46
|
-
def require_rubygems_min_version!
|
|
47
|
-
min_version = Gem::Version.new('2.2')
|
|
48
|
-
|
|
49
|
-
return if min_version <= Gem::Version.new(Gem::VERSION)
|
|
50
|
-
|
|
51
|
-
raise "prune_bundler is not supported on your version of RubyGems. " \
|
|
52
|
-
"You must have RubyGems #{min_version}+ to use this feature."
|
|
53
|
-
end
|
|
54
|
-
|
|
55
44
|
def puma_wild_path
|
|
56
45
|
puma_lib_dir = puma_require_paths.detect { |x| File.exist? File.join(x, '../bin/puma-wild') }
|
|
57
|
-
|
|
58
|
-
end
|
|
46
|
+
return unless puma_lib_dir
|
|
59
47
|
|
|
60
|
-
|
|
61
|
-
bundler_ver = Gem::Version.new(Bundler::VERSION)
|
|
62
|
-
if bundler_ver < Gem::Version.new('2.1.0')
|
|
63
|
-
Bundler.with_clean_env { yield }
|
|
64
|
-
else
|
|
65
|
-
Bundler.with_unbundled_env { yield }
|
|
66
|
-
end
|
|
48
|
+
File.expand_path(File.join(puma_lib_dir, '../bin/puma-wild'))
|
|
67
49
|
end
|
|
68
50
|
|
|
69
51
|
def paths_to_require_after_prune
|