jun-puma 1.0.1-java → 1.0.2-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/lib/puma/puma_http11.jar +0 -0
- metadata +3 -81
- data/bin/puma-wild +0 -25
- data/docs/architecture.md +0 -74
- data/docs/compile_options.md +0 -55
- data/docs/deployment.md +0 -102
- data/docs/fork_worker.md +0 -31
- data/docs/images/puma-connection-flow-no-reactor.png +0 -0
- data/docs/images/puma-connection-flow.png +0 -0
- data/docs/images/puma-general-arch.png +0 -0
- data/docs/jungle/README.md +0 -9
- data/docs/jungle/rc.d/README.md +0 -74
- data/docs/jungle/rc.d/puma +0 -61
- data/docs/jungle/rc.d/puma.conf +0 -10
- data/docs/kubernetes.md +0 -78
- data/docs/nginx.md +0 -80
- data/docs/plugins.md +0 -38
- data/docs/rails_dev_mode.md +0 -28
- data/docs/restart.md +0 -64
- data/docs/signals.md +0 -98
- data/docs/stats.md +0 -142
- data/docs/systemd.md +0 -244
- data/docs/testing_benchmarks_local_files.md +0 -150
- data/docs/testing_test_rackup_ci_files.md +0 -36
- data/ext/puma_http11/PumaHttp11Service.java +0 -17
- data/ext/puma_http11/ext_help.h +0 -15
- data/ext/puma_http11/http11_parser.c +0 -1057
- data/ext/puma_http11/http11_parser.h +0 -65
- data/ext/puma_http11/http11_parser.java.rl +0 -145
- data/ext/puma_http11/http11_parser.rl +0 -149
- data/ext/puma_http11/http11_parser_common.rl +0 -54
- data/ext/puma_http11/mini_ssl.c +0 -832
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +0 -15
- data/ext/puma_http11/org/jruby/puma/Http11.java +0 -226
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +0 -455
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +0 -508
- data/ext/puma_http11/puma_http11.c +0 -492
- data/lib/puma/app/status.rb +0 -96
- data/lib/puma/binder.rb +0 -501
- data/lib/puma/cli.rb +0 -243
- data/lib/puma/client.rb +0 -632
- data/lib/puma/cluster/worker.rb +0 -182
- data/lib/puma/cluster/worker_handle.rb +0 -97
- data/lib/puma/cluster.rb +0 -562
- data/lib/puma/commonlogger.rb +0 -115
- data/lib/puma/configuration.rb +0 -391
- data/lib/puma/const.rb +0 -289
- data/lib/puma/control_cli.rb +0 -316
- data/lib/puma/detect.rb +0 -45
- data/lib/puma/dsl.rb +0 -1204
- data/lib/puma/error_logger.rb +0 -113
- data/lib/puma/events.rb +0 -57
- data/lib/puma/io_buffer.rb +0 -46
- data/lib/puma/jruby_restart.rb +0 -27
- data/lib/puma/json_serialization.rb +0 -96
- data/lib/puma/launcher/bundle_pruner.rb +0 -104
- data/lib/puma/launcher.rb +0 -484
- data/lib/puma/log_writer.rb +0 -147
- data/lib/puma/minissl/context_builder.rb +0 -95
- data/lib/puma/minissl.rb +0 -458
- data/lib/puma/null_io.rb +0 -61
- data/lib/puma/plugin/systemd.rb +0 -90
- data/lib/puma/plugin/tmp_restart.rb +0 -36
- data/lib/puma/plugin.rb +0 -111
- data/lib/puma/rack/builder.rb +0 -297
- data/lib/puma/rack/urlmap.rb +0 -93
- data/lib/puma/rack_default.rb +0 -24
- data/lib/puma/reactor.rb +0 -125
- data/lib/puma/request.rb +0 -671
- data/lib/puma/runner.rb +0 -213
- data/lib/puma/sd_notify.rb +0 -149
- data/lib/puma/server.rb +0 -664
- data/lib/puma/single.rb +0 -69
- data/lib/puma/state_file.rb +0 -68
- data/lib/puma/thread_pool.rb +0 -434
- data/lib/puma/util.rb +0 -141
- data/lib/puma.rb +0 -78
- data/lib/rack/handler/puma.rb +0 -141
- data/tools/Dockerfile +0 -16
- data/tools/trickletest.rb +0 -44
data/lib/puma/configuration.rb
DELETED
@@ -1,391 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'rack/builder'
|
4
|
-
require_relative 'plugin'
|
5
|
-
require_relative 'const'
|
6
|
-
# note that dsl is loaded at end of file, requires ConfigDefault constants
|
7
|
-
|
8
|
-
module Puma
|
9
|
-
# A class used for storing "leveled" configuration options.
|
10
|
-
#
|
11
|
-
# In this class any "user" specified options take precedence over any
|
12
|
-
# "file" specified options, take precedence over any "default" options.
|
13
|
-
#
|
14
|
-
# User input is preferred over "defaults":
|
15
|
-
# user_options = { foo: "bar" }
|
16
|
-
# default_options = { foo: "zoo" }
|
17
|
-
# options = UserFileDefaultOptions.new(user_options, default_options)
|
18
|
-
# puts options[:foo]
|
19
|
-
# # => "bar"
|
20
|
-
#
|
21
|
-
# All values can be accessed via `all_of`
|
22
|
-
#
|
23
|
-
# puts options.all_of(:foo)
|
24
|
-
# # => ["bar", "zoo"]
|
25
|
-
#
|
26
|
-
# A "file" option can be set. This config will be preferred over "default" options
|
27
|
-
# but will defer to any available "user" specified options.
|
28
|
-
#
|
29
|
-
# user_options = { foo: "bar" }
|
30
|
-
# default_options = { rackup: "zoo.rb" }
|
31
|
-
# options = UserFileDefaultOptions.new(user_options, default_options)
|
32
|
-
# options.file_options[:rackup] = "sup.rb"
|
33
|
-
# puts options[:rackup]
|
34
|
-
# # => "sup.rb"
|
35
|
-
#
|
36
|
-
# The "default" options can be set via procs. These are resolved during runtime
|
37
|
-
# via calls to `finalize_values`
|
38
|
-
class UserFileDefaultOptions
|
39
|
-
def initialize(user_options, default_options)
|
40
|
-
@user_options = user_options
|
41
|
-
@file_options = {}
|
42
|
-
@default_options = default_options
|
43
|
-
end
|
44
|
-
|
45
|
-
attr_reader :user_options, :file_options, :default_options
|
46
|
-
|
47
|
-
def [](key)
|
48
|
-
fetch(key)
|
49
|
-
end
|
50
|
-
|
51
|
-
def []=(key, value)
|
52
|
-
user_options[key] = value
|
53
|
-
end
|
54
|
-
|
55
|
-
def fetch(key, default_value = nil)
|
56
|
-
return user_options[key] if user_options.key?(key)
|
57
|
-
return file_options[key] if file_options.key?(key)
|
58
|
-
return default_options[key] if default_options.key?(key)
|
59
|
-
|
60
|
-
default_value
|
61
|
-
end
|
62
|
-
|
63
|
-
def all_of(key)
|
64
|
-
user = user_options[key]
|
65
|
-
file = file_options[key]
|
66
|
-
default = default_options[key]
|
67
|
-
|
68
|
-
user = [user] unless user.is_a?(Array)
|
69
|
-
file = [file] unless file.is_a?(Array)
|
70
|
-
default = [default] unless default.is_a?(Array)
|
71
|
-
|
72
|
-
user.compact!
|
73
|
-
file.compact!
|
74
|
-
default.compact!
|
75
|
-
|
76
|
-
user + file + default
|
77
|
-
end
|
78
|
-
|
79
|
-
def finalize_values
|
80
|
-
@default_options.each do |k,v|
|
81
|
-
if v.respond_to? :call
|
82
|
-
@default_options[k] = v.call
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def final_options
|
88
|
-
default_options
|
89
|
-
.merge(file_options)
|
90
|
-
.merge(user_options)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# The main configuration class of Puma.
|
95
|
-
#
|
96
|
-
# It can be initialized with a set of "user" options and "default" options.
|
97
|
-
# Defaults will be merged with `Configuration.puma_default_options`.
|
98
|
-
#
|
99
|
-
# This class works together with 2 main other classes the `UserFileDefaultOptions`
|
100
|
-
# which stores configuration options in order so the precedence is that user
|
101
|
-
# set configuration wins over "file" based configuration wins over "default"
|
102
|
-
# configuration. These configurations are set via the `DSL` class. This
|
103
|
-
# class powers the Puma config file syntax and does double duty as a configuration
|
104
|
-
# DSL used by the `Puma::CLI` and Puma rack handler.
|
105
|
-
#
|
106
|
-
# It also handles loading plugins.
|
107
|
-
#
|
108
|
-
# [Note:]
|
109
|
-
# `:port` and `:host` are not valid keys. By the time they make it to the
|
110
|
-
# configuration options they are expected to be incorporated into a `:binds` key.
|
111
|
-
# Under the hood the DSL maps `port` and `host` calls to `:binds`
|
112
|
-
#
|
113
|
-
# config = Configuration.new({}) do |user_config, file_config, default_config|
|
114
|
-
# user_config.port 3003
|
115
|
-
# end
|
116
|
-
# config.load
|
117
|
-
# puts config.options[:port]
|
118
|
-
# # => 3003
|
119
|
-
#
|
120
|
-
# It is expected that `load` is called on the configuration instance after setting
|
121
|
-
# config. This method expands any values in `config_file` and puts them into the
|
122
|
-
# correct configuration option hash.
|
123
|
-
#
|
124
|
-
# Once all configuration is complete it is expected that `clamp` will be called
|
125
|
-
# on the instance. This will expand any procs stored under "default" values. This
|
126
|
-
# is done because an environment variable may have been modified while loading
|
127
|
-
# configuration files.
|
128
|
-
class Configuration
|
129
|
-
DEFAULTS = {
|
130
|
-
auto_trim_time: 30,
|
131
|
-
binds: ['tcp://0.0.0.0:9292'.freeze],
|
132
|
-
clean_thread_locals: false,
|
133
|
-
debug: false,
|
134
|
-
early_hints: nil,
|
135
|
-
environment: 'development'.freeze,
|
136
|
-
# Number of seconds to wait until we get the first data for the request.
|
137
|
-
first_data_timeout: 30,
|
138
|
-
# Number of seconds to wait until the next request before shutting down.
|
139
|
-
idle_timeout: nil,
|
140
|
-
io_selector_backend: :auto,
|
141
|
-
log_requests: false,
|
142
|
-
logger: STDOUT,
|
143
|
-
# How many requests to attempt inline before sending a client back to
|
144
|
-
# the reactor to be subject to normal ordering. The idea here is that
|
145
|
-
# we amortize the cost of going back to the reactor for a well behaved
|
146
|
-
# but very "greedy" client across 10 requests. This prevents a not
|
147
|
-
# well behaved client from monopolizing the thread forever.
|
148
|
-
max_fast_inline: 10,
|
149
|
-
max_threads: Puma.mri? ? 5 : 16,
|
150
|
-
min_threads: 0,
|
151
|
-
mode: :http,
|
152
|
-
mutate_stdout_and_stderr_to_sync_on_write: true,
|
153
|
-
out_of_band: [],
|
154
|
-
# Number of seconds for another request within a persistent session.
|
155
|
-
persistent_timeout: 20,
|
156
|
-
queue_requests: true,
|
157
|
-
rackup: 'config.ru'.freeze,
|
158
|
-
raise_exception_on_sigterm: true,
|
159
|
-
reaping_time: 1,
|
160
|
-
remote_address: :socket,
|
161
|
-
silence_single_worker_warning: false,
|
162
|
-
silence_fork_callback_warning: false,
|
163
|
-
tag: File.basename(Dir.getwd),
|
164
|
-
tcp_host: '0.0.0.0'.freeze,
|
165
|
-
tcp_port: 9292,
|
166
|
-
wait_for_less_busy_worker: 0.005,
|
167
|
-
worker_boot_timeout: 60,
|
168
|
-
worker_check_interval: 5,
|
169
|
-
worker_culling_strategy: :youngest,
|
170
|
-
worker_shutdown_timeout: 30,
|
171
|
-
worker_timeout: 60,
|
172
|
-
workers: 0,
|
173
|
-
http_content_length_limit: nil
|
174
|
-
}
|
175
|
-
|
176
|
-
def initialize(user_options={}, default_options = {}, &block)
|
177
|
-
default_options = self.puma_default_options.merge(default_options)
|
178
|
-
|
179
|
-
@options = UserFileDefaultOptions.new(user_options, default_options)
|
180
|
-
@plugins = PluginLoader.new
|
181
|
-
@user_dsl = DSL.new(@options.user_options, self)
|
182
|
-
@file_dsl = DSL.new(@options.file_options, self)
|
183
|
-
@default_dsl = DSL.new(@options.default_options, self)
|
184
|
-
|
185
|
-
if !@options[:prune_bundler]
|
186
|
-
default_options[:preload_app] = (@options[:workers] > 1) && Puma.forkable?
|
187
|
-
end
|
188
|
-
|
189
|
-
if block
|
190
|
-
configure(&block)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
attr_reader :options, :plugins
|
195
|
-
|
196
|
-
def configure
|
197
|
-
yield @user_dsl, @file_dsl, @default_dsl
|
198
|
-
ensure
|
199
|
-
@user_dsl._offer_plugins
|
200
|
-
@file_dsl._offer_plugins
|
201
|
-
@default_dsl._offer_plugins
|
202
|
-
end
|
203
|
-
|
204
|
-
def initialize_copy(other)
|
205
|
-
@conf = nil
|
206
|
-
@cli_options = nil
|
207
|
-
@options = @options.dup
|
208
|
-
end
|
209
|
-
|
210
|
-
def flatten
|
211
|
-
dup.flatten!
|
212
|
-
end
|
213
|
-
|
214
|
-
def flatten!
|
215
|
-
@options = @options.flatten
|
216
|
-
self
|
217
|
-
end
|
218
|
-
|
219
|
-
def puma_default_options
|
220
|
-
defaults = DEFAULTS.dup
|
221
|
-
puma_options_from_env.each { |k,v| defaults[k] = v if v }
|
222
|
-
defaults
|
223
|
-
end
|
224
|
-
|
225
|
-
def puma_options_from_env
|
226
|
-
min = ENV['PUMA_MIN_THREADS'] || ENV['MIN_THREADS']
|
227
|
-
max = ENV['PUMA_MAX_THREADS'] || ENV['MAX_THREADS']
|
228
|
-
workers = ENV['WEB_CONCURRENCY']
|
229
|
-
|
230
|
-
{
|
231
|
-
min_threads: min && Integer(min),
|
232
|
-
max_threads: max && Integer(max),
|
233
|
-
workers: workers && Integer(workers),
|
234
|
-
environment: ENV['APP_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV'],
|
235
|
-
}
|
236
|
-
end
|
237
|
-
|
238
|
-
def load
|
239
|
-
config_files.each { |config_file| @file_dsl._load_from(config_file) }
|
240
|
-
|
241
|
-
@options
|
242
|
-
end
|
243
|
-
|
244
|
-
def config_files
|
245
|
-
files = @options.all_of(:config_files)
|
246
|
-
|
247
|
-
return [] if files == ['-']
|
248
|
-
return files if files.any?
|
249
|
-
|
250
|
-
first_default_file = %W(config/puma/#{@options[:environment]}.rb config/puma.rb).find do |f|
|
251
|
-
File.exist?(f)
|
252
|
-
end
|
253
|
-
|
254
|
-
[first_default_file]
|
255
|
-
end
|
256
|
-
|
257
|
-
# Call once all configuration (included from rackup files)
|
258
|
-
# is loaded to flesh out any defaults
|
259
|
-
def clamp
|
260
|
-
@options.finalize_values
|
261
|
-
end
|
262
|
-
|
263
|
-
# Injects the Configuration object into the env
|
264
|
-
class ConfigMiddleware
|
265
|
-
def initialize(config, app)
|
266
|
-
@config = config
|
267
|
-
@app = app
|
268
|
-
end
|
269
|
-
|
270
|
-
def call(env)
|
271
|
-
env[Const::PUMA_CONFIG] = @config
|
272
|
-
@app.call(env)
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
# Indicate if there is a properly configured app
|
277
|
-
#
|
278
|
-
def app_configured?
|
279
|
-
@options[:app] || File.exist?(rackup)
|
280
|
-
end
|
281
|
-
|
282
|
-
def rackup
|
283
|
-
@options[:rackup]
|
284
|
-
end
|
285
|
-
|
286
|
-
# Load the specified rackup file, pull options from
|
287
|
-
# the rackup file, and set @app.
|
288
|
-
#
|
289
|
-
def app
|
290
|
-
found = options[:app] || load_rackup
|
291
|
-
|
292
|
-
if @options[:log_requests]
|
293
|
-
require_relative 'commonlogger'
|
294
|
-
logger = @options[:logger]
|
295
|
-
found = CommonLogger.new(found, logger)
|
296
|
-
end
|
297
|
-
|
298
|
-
ConfigMiddleware.new(self, found)
|
299
|
-
end
|
300
|
-
|
301
|
-
# Return which environment we're running in
|
302
|
-
def environment
|
303
|
-
@options[:environment]
|
304
|
-
end
|
305
|
-
|
306
|
-
def load_plugin(name)
|
307
|
-
@plugins.create name
|
308
|
-
end
|
309
|
-
|
310
|
-
# @param key [:Symbol] hook to run
|
311
|
-
# @param arg [Launcher, Int] `:on_restart` passes Launcher
|
312
|
-
#
|
313
|
-
def run_hooks(key, arg, log_writer, hook_data = nil)
|
314
|
-
@options.all_of(key).each do |b|
|
315
|
-
begin
|
316
|
-
if Array === b
|
317
|
-
hook_data[b[1]] ||= Hash.new
|
318
|
-
b[0].call arg, hook_data[b[1]]
|
319
|
-
else
|
320
|
-
b.call arg
|
321
|
-
end
|
322
|
-
rescue => e
|
323
|
-
log_writer.log "WARNING hook #{key} failed with exception (#{e.class}) #{e.message}"
|
324
|
-
log_writer.debug e.backtrace.join("\n")
|
325
|
-
end
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
def final_options
|
330
|
-
@options.final_options
|
331
|
-
end
|
332
|
-
|
333
|
-
def self.temp_path
|
334
|
-
require 'tmpdir'
|
335
|
-
|
336
|
-
t = (Time.now.to_f * 1000).to_i
|
337
|
-
"#{Dir.tmpdir}/puma-status-#{t}-#{$$}"
|
338
|
-
end
|
339
|
-
|
340
|
-
private
|
341
|
-
|
342
|
-
# Load and use the normal Rack builder if we can, otherwise
|
343
|
-
# fallback to our minimal version.
|
344
|
-
def rack_builder
|
345
|
-
# Load bundler now if we can so that we can pickup rack from
|
346
|
-
# a Gemfile
|
347
|
-
if ENV.key? 'PUMA_BUNDLER_PRUNED'
|
348
|
-
begin
|
349
|
-
require 'bundler/setup'
|
350
|
-
rescue LoadError
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
begin
|
355
|
-
require 'rack'
|
356
|
-
require 'rack/builder'
|
357
|
-
rescue LoadError
|
358
|
-
# ok, use builtin version
|
359
|
-
return Puma::Rack::Builder
|
360
|
-
else
|
361
|
-
return ::Rack::Builder
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
def load_rackup
|
366
|
-
raise "Missing rackup file '#{rackup}'" unless File.exist?(rackup)
|
367
|
-
|
368
|
-
rack_app, rack_options = rack_builder.parse_file(rackup)
|
369
|
-
rack_options = rack_options || {}
|
370
|
-
|
371
|
-
@options.file_options.merge!(rack_options)
|
372
|
-
|
373
|
-
config_ru_binds = []
|
374
|
-
rack_options.each do |k, v|
|
375
|
-
config_ru_binds << v if k.to_s.start_with?("bind")
|
376
|
-
end
|
377
|
-
|
378
|
-
@options.file_options[:binds] = config_ru_binds unless config_ru_binds.empty?
|
379
|
-
|
380
|
-
rack_app
|
381
|
-
end
|
382
|
-
|
383
|
-
def self.random_token
|
384
|
-
require 'securerandom' unless defined?(SecureRandom)
|
385
|
-
|
386
|
-
SecureRandom.hex(16)
|
387
|
-
end
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
391
|
-
require_relative 'dsl'
|
data/lib/puma/const.rb
DELETED
@@ -1,289 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Puma
|
5
|
-
class UnsupportedOption < RuntimeError
|
6
|
-
end
|
7
|
-
|
8
|
-
# Every standard HTTP code mapped to the appropriate message. These are
|
9
|
-
# used so frequently that they are placed directly in Puma for easy
|
10
|
-
# access rather than Puma::Const itself.
|
11
|
-
|
12
|
-
# Every standard HTTP code mapped to the appropriate message.
|
13
|
-
# Generated with:
|
14
|
-
# curl -s https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv | \
|
15
|
-
# ruby -ne 'm = /^(\d{3}),(?!Unassigned|\(Unused\))([^,]+)/.match($_) and \
|
16
|
-
# puts "#{m[1]} => \x27#{m[2].strip}\x27,"'
|
17
|
-
HTTP_STATUS_CODES = {
|
18
|
-
100 => 'Continue',
|
19
|
-
101 => 'Switching Protocols',
|
20
|
-
102 => 'Processing',
|
21
|
-
103 => 'Early Hints',
|
22
|
-
200 => 'OK',
|
23
|
-
201 => 'Created',
|
24
|
-
202 => 'Accepted',
|
25
|
-
203 => 'Non-Authoritative Information',
|
26
|
-
204 => 'No Content',
|
27
|
-
205 => 'Reset Content',
|
28
|
-
206 => 'Partial Content',
|
29
|
-
207 => 'Multi-Status',
|
30
|
-
208 => 'Already Reported',
|
31
|
-
226 => 'IM Used',
|
32
|
-
300 => 'Multiple Choices',
|
33
|
-
301 => 'Moved Permanently',
|
34
|
-
302 => 'Found',
|
35
|
-
303 => 'See Other',
|
36
|
-
304 => 'Not Modified',
|
37
|
-
305 => 'Use Proxy',
|
38
|
-
307 => 'Temporary Redirect',
|
39
|
-
308 => 'Permanent Redirect',
|
40
|
-
400 => 'Bad Request',
|
41
|
-
401 => 'Unauthorized',
|
42
|
-
402 => 'Payment Required',
|
43
|
-
403 => 'Forbidden',
|
44
|
-
404 => 'Not Found',
|
45
|
-
405 => 'Method Not Allowed',
|
46
|
-
406 => 'Not Acceptable',
|
47
|
-
407 => 'Proxy Authentication Required',
|
48
|
-
408 => 'Request Timeout',
|
49
|
-
409 => 'Conflict',
|
50
|
-
410 => 'Gone',
|
51
|
-
411 => 'Length Required',
|
52
|
-
412 => 'Precondition Failed',
|
53
|
-
413 => 'Content Too Large',
|
54
|
-
414 => 'URI Too Long',
|
55
|
-
415 => 'Unsupported Media Type',
|
56
|
-
416 => 'Range Not Satisfiable',
|
57
|
-
417 => 'Expectation Failed',
|
58
|
-
421 => 'Misdirected Request',
|
59
|
-
422 => 'Unprocessable Content',
|
60
|
-
423 => 'Locked',
|
61
|
-
424 => 'Failed Dependency',
|
62
|
-
425 => 'Too Early',
|
63
|
-
426 => 'Upgrade Required',
|
64
|
-
428 => 'Precondition Required',
|
65
|
-
429 => 'Too Many Requests',
|
66
|
-
431 => 'Request Header Fields Too Large',
|
67
|
-
451 => 'Unavailable For Legal Reasons',
|
68
|
-
500 => 'Internal Server Error',
|
69
|
-
501 => 'Not Implemented',
|
70
|
-
502 => 'Bad Gateway',
|
71
|
-
503 => 'Service Unavailable',
|
72
|
-
504 => 'Gateway Timeout',
|
73
|
-
505 => 'HTTP Version Not Supported',
|
74
|
-
506 => 'Variant Also Negotiates',
|
75
|
-
507 => 'Insufficient Storage',
|
76
|
-
508 => 'Loop Detected',
|
77
|
-
510 => 'Not Extended (OBSOLETED)',
|
78
|
-
511 => 'Network Authentication Required'
|
79
|
-
}.freeze
|
80
|
-
|
81
|
-
# For some HTTP status codes the client only expects headers.
|
82
|
-
#
|
83
|
-
|
84
|
-
STATUS_WITH_NO_ENTITY_BODY = {
|
85
|
-
204 => true,
|
86
|
-
205 => true,
|
87
|
-
304 => true
|
88
|
-
}.freeze
|
89
|
-
|
90
|
-
# Frequently used constants when constructing requests or responses. Many times
|
91
|
-
# the constant just refers to a string with the same contents. Using these constants
|
92
|
-
# gave about a 3% to 10% performance improvement over using the strings directly.
|
93
|
-
#
|
94
|
-
# The constants are frozen because Hash#[]= when called with a String key dups
|
95
|
-
# the String UNLESS the String is frozen. This saves us therefore 2 object
|
96
|
-
# allocations when creating the env hash later.
|
97
|
-
#
|
98
|
-
# While Puma does try to emulate the CGI/1.2 protocol, it does not use the REMOTE_IDENT,
|
99
|
-
# REMOTE_USER, or REMOTE_HOST parameters since those are either a security problem or
|
100
|
-
# too taxing on performance.
|
101
|
-
module Const
|
102
|
-
|
103
|
-
PUMA_VERSION = VERSION = "1.0.1"
|
104
|
-
CODE_NAME = "The Eagle of Durango - Jun - 6.4.1"
|
105
|
-
|
106
|
-
PUMA_SERVER_STRING = ["puma", PUMA_VERSION, CODE_NAME].join(" ").freeze
|
107
|
-
|
108
|
-
FAST_TRACK_KA_TIMEOUT = 0.2
|
109
|
-
|
110
|
-
# How long to wait when getting some write blocking on the socket when
|
111
|
-
# sending data back
|
112
|
-
WRITE_TIMEOUT = 10
|
113
|
-
|
114
|
-
# The original URI requested by the client.
|
115
|
-
REQUEST_URI= "REQUEST_URI"
|
116
|
-
REQUEST_PATH = "REQUEST_PATH"
|
117
|
-
QUERY_STRING = "QUERY_STRING"
|
118
|
-
CONTENT_LENGTH = "CONTENT_LENGTH"
|
119
|
-
|
120
|
-
PATH_INFO = "PATH_INFO"
|
121
|
-
|
122
|
-
PUMA_TMP_BASE = "puma"
|
123
|
-
|
124
|
-
ERROR_RESPONSE = {
|
125
|
-
# Indicate that we couldn't parse the request
|
126
|
-
400 => "HTTP/1.1 400 Bad Request\r\n\r\n",
|
127
|
-
# The standard empty 404 response for bad requests. Use Error4040Handler for custom stuff.
|
128
|
-
404 => "HTTP/1.1 404 Not Found\r\nConnection: close\r\n\r\n",
|
129
|
-
# The standard empty 408 response for requests that timed out.
|
130
|
-
408 => "HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n",
|
131
|
-
# Indicate that there was an internal error, obviously.
|
132
|
-
500 => "HTTP/1.1 500 Internal Server Error\r\n\r\n",
|
133
|
-
# Incorrect or invalid header value
|
134
|
-
501 => "HTTP/1.1 501 Not Implemented\r\n\r\n",
|
135
|
-
# A common header for indicating the server is too busy. Not used yet.
|
136
|
-
503 => "HTTP/1.1 503 Service Unavailable\r\n\r\n"
|
137
|
-
}.freeze
|
138
|
-
|
139
|
-
# The basic max request size we'll try to read.
|
140
|
-
CHUNK_SIZE = 16 * 1024
|
141
|
-
|
142
|
-
# This is the maximum header that is allowed before a client is booted. The parser detects
|
143
|
-
# this, but we'd also like to do this as well.
|
144
|
-
MAX_HEADER = 1024 * (80 + 32)
|
145
|
-
|
146
|
-
# Maximum request body size before it is moved out of memory and into a tempfile for reading.
|
147
|
-
MAX_BODY = MAX_HEADER
|
148
|
-
|
149
|
-
REQUEST_METHOD = "REQUEST_METHOD"
|
150
|
-
HEAD = "HEAD"
|
151
|
-
|
152
|
-
# based on https://www.rfc-editor.org/rfc/rfc9110.html#name-overview,
|
153
|
-
# with CONNECT removed, and PATCH added
|
154
|
-
SUPPORTED_HTTP_METHODS = %w[HEAD GET POST PUT DELETE OPTIONS TRACE PATCH].freeze
|
155
|
-
|
156
|
-
# list from https://www.iana.org/assignments/http-methods/http-methods.xhtml
|
157
|
-
# as of 04-May-23
|
158
|
-
IANA_HTTP_METHODS = %w[
|
159
|
-
ACL
|
160
|
-
BASELINE-CONTROL
|
161
|
-
BIND
|
162
|
-
CHECKIN
|
163
|
-
CHECKOUT
|
164
|
-
CONNECT
|
165
|
-
COPY
|
166
|
-
DELETE
|
167
|
-
GET
|
168
|
-
HEAD
|
169
|
-
LABEL
|
170
|
-
LINK
|
171
|
-
LOCK
|
172
|
-
MERGE
|
173
|
-
MKACTIVITY
|
174
|
-
MKCALENDAR
|
175
|
-
MKCOL
|
176
|
-
MKREDIRECTREF
|
177
|
-
MKWORKSPACE
|
178
|
-
MOVE
|
179
|
-
OPTIONS
|
180
|
-
ORDERPATCH
|
181
|
-
PATCH
|
182
|
-
POST
|
183
|
-
PRI
|
184
|
-
PROPFIND
|
185
|
-
PROPPATCH
|
186
|
-
PUT
|
187
|
-
REBIND
|
188
|
-
REPORT
|
189
|
-
SEARCH
|
190
|
-
TRACE
|
191
|
-
UNBIND
|
192
|
-
UNCHECKOUT
|
193
|
-
UNLINK
|
194
|
-
UNLOCK
|
195
|
-
UPDATE
|
196
|
-
UPDATEREDIRECTREF
|
197
|
-
VERSION-CONTROL
|
198
|
-
].freeze
|
199
|
-
|
200
|
-
# ETag is based on the apache standard of hex mtime-size-inode (inode is 0 on win32)
|
201
|
-
LINE_END = "\r\n"
|
202
|
-
REMOTE_ADDR = "REMOTE_ADDR"
|
203
|
-
HTTP_X_FORWARDED_FOR = "HTTP_X_FORWARDED_FOR"
|
204
|
-
HTTP_X_FORWARDED_SSL = "HTTP_X_FORWARDED_SSL"
|
205
|
-
HTTP_X_FORWARDED_SCHEME = "HTTP_X_FORWARDED_SCHEME"
|
206
|
-
HTTP_X_FORWARDED_PROTO = "HTTP_X_FORWARDED_PROTO"
|
207
|
-
|
208
|
-
SERVER_NAME = "SERVER_NAME"
|
209
|
-
SERVER_PORT = "SERVER_PORT"
|
210
|
-
HTTP_HOST = "HTTP_HOST"
|
211
|
-
PORT_80 = "80"
|
212
|
-
PORT_443 = "443"
|
213
|
-
LOCALHOST = "localhost"
|
214
|
-
LOCALHOST_IPV4 = "127.0.0.1"
|
215
|
-
LOCALHOST_IPV6 = "::1"
|
216
|
-
UNSPECIFIED_IPV4 = "0.0.0.0"
|
217
|
-
UNSPECIFIED_IPV6 = "::"
|
218
|
-
|
219
|
-
SERVER_PROTOCOL = "SERVER_PROTOCOL"
|
220
|
-
HTTP_11 = "HTTP/1.1"
|
221
|
-
|
222
|
-
SERVER_SOFTWARE = "SERVER_SOFTWARE"
|
223
|
-
GATEWAY_INTERFACE = "GATEWAY_INTERFACE"
|
224
|
-
CGI_VER = "CGI/1.2"
|
225
|
-
|
226
|
-
STOP_COMMAND = "?"
|
227
|
-
HALT_COMMAND = "!"
|
228
|
-
RESTART_COMMAND = "R"
|
229
|
-
|
230
|
-
RACK_INPUT = "rack.input"
|
231
|
-
RACK_URL_SCHEME = "rack.url_scheme"
|
232
|
-
RACK_AFTER_REPLY = "rack.after_reply"
|
233
|
-
PUMA_SOCKET = "puma.socket"
|
234
|
-
PUMA_CONFIG = "puma.config"
|
235
|
-
PUMA_PEERCERT = "puma.peercert"
|
236
|
-
|
237
|
-
HTTP = "http"
|
238
|
-
HTTPS = "https"
|
239
|
-
|
240
|
-
HTTPS_KEY = "HTTPS"
|
241
|
-
|
242
|
-
HTTP_VERSION = "HTTP_VERSION"
|
243
|
-
HTTP_CONNECTION = "HTTP_CONNECTION"
|
244
|
-
HTTP_EXPECT = "HTTP_EXPECT"
|
245
|
-
CONTINUE = "100-continue"
|
246
|
-
|
247
|
-
HTTP_11_100 = "HTTP/1.1 100 Continue\r\n\r\n"
|
248
|
-
HTTP_11_200 = "HTTP/1.1 200 OK\r\n"
|
249
|
-
HTTP_10_200 = "HTTP/1.0 200 OK\r\n"
|
250
|
-
|
251
|
-
CLOSE = "close"
|
252
|
-
KEEP_ALIVE = "keep-alive"
|
253
|
-
|
254
|
-
CONTENT_LENGTH2 = "content-length"
|
255
|
-
CONTENT_LENGTH_S = "Content-Length: "
|
256
|
-
TRANSFER_ENCODING = "transfer-encoding"
|
257
|
-
TRANSFER_ENCODING2 = "HTTP_TRANSFER_ENCODING"
|
258
|
-
|
259
|
-
CONNECTION_CLOSE = "Connection: close\r\n"
|
260
|
-
CONNECTION_KEEP_ALIVE = "Connection: Keep-Alive\r\n"
|
261
|
-
|
262
|
-
TRANSFER_ENCODING_CHUNKED = "Transfer-Encoding: chunked\r\n"
|
263
|
-
CLOSE_CHUNKED = "0\r\n\r\n"
|
264
|
-
|
265
|
-
CHUNKED = "chunked"
|
266
|
-
|
267
|
-
COLON = ": "
|
268
|
-
|
269
|
-
NEWLINE = "\n"
|
270
|
-
|
271
|
-
HIJACK_P = "rack.hijack?"
|
272
|
-
HIJACK = "rack.hijack"
|
273
|
-
HIJACK_IO = "rack.hijack_io"
|
274
|
-
|
275
|
-
EARLY_HINTS = "rack.early_hints"
|
276
|
-
|
277
|
-
# Illegal character in the key or value of response header
|
278
|
-
DQUOTE = "\""
|
279
|
-
HTTP_HEADER_DELIMITER = Regexp.escape("(),/:;<=>?@[]{}\\").freeze
|
280
|
-
ILLEGAL_HEADER_KEY_REGEX = /[\x00-\x20#{DQUOTE}#{HTTP_HEADER_DELIMITER}]/.freeze
|
281
|
-
# header values can contain HTAB?
|
282
|
-
ILLEGAL_HEADER_VALUE_REGEX = /[\x00-\x08\x0A-\x1F]/.freeze
|
283
|
-
|
284
|
-
# Banned keys of response header
|
285
|
-
BANNED_HEADER_KEY = /\A(rack\.|status\z)/.freeze
|
286
|
-
|
287
|
-
PROXY_PROTOCOL_V1_REGEX = /^PROXY (?:TCP4|TCP6|UNKNOWN) ([^\r]+)\r\n/.freeze
|
288
|
-
end
|
289
|
-
end
|