Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build proper url instead of interpolating in Puma::DSL#port #2521

Merged
merged 1 commit into from Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -12,6 +12,7 @@
* Fix compiler warnings, but skipped warnings related to ragel state machine generated code ([#1953])
* Fix phased restart errors related to nio4r gem when using the Puma control server (#2516)
* Add `#string` method to `Puma::NullIO` ([#2520])
* Fix binding via Rack handler to IPv6 addresses (#2521)

## 5.1.1 / 2020-12-10

Expand Down
2 changes: 1 addition & 1 deletion lib/puma/dsl.rb
Expand Up @@ -257,7 +257,7 @@ def bind_to_activated_sockets(bind=true)
# port 9292
def port(port, host=nil)
host ||= default_host
bind "tcp://#{host}:#{port}"
bind URI::Generic.build(scheme: 'tcp', host: host, port: Integer(port)).to_s
end

# Define how long persistent connections can be idle before Puma closes them.
Expand Down
8 changes: 8 additions & 0 deletions test/test_rack_handler.rb
Expand Up @@ -95,6 +95,14 @@ def test_host_uses_supplied_port_default

assert_equal ["tcp://#{user_host}:#{user_port}"], conf.options[:binds]
end

def test_ipv6_host_supplied_port_default
@options[:Host] = "::1"
conf = Rack::Handler::Puma.config(->{}, @options)
conf.load

assert_equal ["tcp://[::1]:9292"], conf.options[:binds]
end
end

class TestUserSuppliedOptionsIsEmpty < Minitest::Test
Expand Down