mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Load the configuration before passing it to the binder: (#2897)
* Load the configuration before passing it to the binder: * Replace unit tests with integration ones
This commit is contained in:
parent
dbf450bdd2
commit
de314e47e7
5 changed files with 29 additions and 25 deletions
|
@ -52,17 +52,17 @@ module Puma
|
|||
@original_argv = @argv.dup
|
||||
@config = conf
|
||||
|
||||
# Advertise the Configuration
|
||||
Puma.cli_config = @config if defined?(Puma.cli_config)
|
||||
|
||||
@config.load
|
||||
|
||||
@binder = Binder.new(@log_writer, conf)
|
||||
@binder.create_inherited_fds(ENV).each { |k| ENV.delete k }
|
||||
@binder.create_activated_fds(ENV).each { |k| ENV.delete k }
|
||||
|
||||
@environment = conf.environment
|
||||
|
||||
# Advertise the Configuration
|
||||
Puma.cli_config = @config if defined?(Puma.cli_config)
|
||||
|
||||
@config.load
|
||||
|
||||
if @config.options[:bind_to_activated_sockets]
|
||||
@config.options[:binds] = @binder.synthesize_binds_from_activated_fs(
|
||||
@config.options[:binds],
|
||||
|
|
1
test/config/rack_url_scheme.rb
Normal file
1
test/config/rack_url_scheme.rb
Normal file
|
@ -0,0 +1 @@
|
|||
rack_url_scheme "https"
|
1
test/rackup/url_scheme.ru
Normal file
1
test/rackup/url_scheme.ru
Normal file
|
@ -0,0 +1 @@
|
|||
run lambda { |env| [200, {"Content-Type" => "text/plain"}, [env["rack.url_scheme"]]] }
|
|
@ -53,6 +53,28 @@ class TestIntegrationSingle < TestIntegration
|
|||
assert_equal 0, status
|
||||
end
|
||||
|
||||
def test_rack_url_scheme_default
|
||||
skip_unless_signal_exist? :TERM
|
||||
|
||||
cli_server("test/rackup/url_scheme.ru")
|
||||
|
||||
reply = read_body(connect)
|
||||
stop_server
|
||||
|
||||
assert_match("http", reply)
|
||||
end
|
||||
|
||||
def test_conf_is_loaded_before_passing_it_to_binder
|
||||
skip_unless_signal_exist? :TERM
|
||||
|
||||
cli_server("-C test/config/rack_url_scheme.rb test/rackup/url_scheme.ru")
|
||||
|
||||
reply = read_body(connect)
|
||||
stop_server
|
||||
|
||||
assert_match("https", reply)
|
||||
end
|
||||
|
||||
def test_prefer_rackup_file_specified_by_cli
|
||||
skip_unless_signal_exist? :TERM
|
||||
|
||||
|
|
|
@ -1368,26 +1368,6 @@ EOF
|
|||
test_drain_on_shutdown false
|
||||
end
|
||||
|
||||
def test_rack_url_scheme_dflt
|
||||
server_run
|
||||
|
||||
data = send_http_and_read "GET / HTTP/1.0\r\n\r\n"
|
||||
assert_equal "http", data.split("\r\n").last
|
||||
end
|
||||
|
||||
def test_rack_url_scheme_user
|
||||
@port = UniquePort.call
|
||||
opts = { rack_url_scheme: 'user', binds: ["tcp://#{@host}:#{@port}"] }
|
||||
conf = Puma::Configuration.new(opts).tap(&:clamp)
|
||||
@server = Puma::Server.new @app, @log_writer, @events, conf.options
|
||||
@server.inherit_binder Puma::Binder.new(@log_writer, conf)
|
||||
@server.binder.parse conf.options[:binds], @log_writer
|
||||
@server.run
|
||||
|
||||
data = send_http_and_read "GET / HTTP/1.0\r\n\r\n"
|
||||
assert_equal "user", data.split("\r\n").last
|
||||
end
|
||||
|
||||
def test_remote_address_header
|
||||
server_run(remote_address: :header, remote_address_header: 'HTTP_X_REMOTE_IP') do |env|
|
||||
[200, {}, [env['REMOTE_ADDR']]]
|
||||
|
|
Loading…
Reference in a new issue