From 4ecd9359a87cd97fe81d51881468766fa49e671d Mon Sep 17 00:00:00 2001 From: Christian Bruckmayer Date: Mon, 9 Mar 2020 19:29:34 +0000 Subject: [PATCH] Log binding on http:// for TCP bindings to make it clickable Fix https://github.com/puma/puma/issues/2166 --- History.md | 1 + lib/puma/binder.rb | 2 +- test/test_binder.rb | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index 2555344d..95c7cd98 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,7 @@ * Changed #connected_port to #connected_ports (#2076) * `--control` has been removed. Use `--control-url` (#1487) * `worker_directory` has been removed. Use `directory` + * Log binding on http:// for TCP bindings to make it clickable * Bugfixes * Windows update extconf.rb for use with ssp and varied Ruby/MSYS2 combinations (#2069) diff --git a/lib/puma/binder.rb b/lib/puma/binder.rb index 6749d16a..78d97f52 100644 --- a/lib/puma/binder.rb +++ b/lib/puma/binder.rb @@ -115,7 +115,7 @@ module Puma i.local_address.ip_unpack.join(':') end - logger.log "* #{log_msg} on tcp://#{addr}" + logger.log "* #{log_msg} on http://#{addr}" end end diff --git a/test/test_binder.rb b/test/test_binder.rb index 02e4c2e7..60da1dfa 100644 --- a/test/test_binder.rb +++ b/test/test_binder.rb @@ -64,7 +64,7 @@ class TestBinder < TestBinderBase def test_correct_zero_port @binder.parse ["tcp://localhost:0"], @events - m = %r!tcp://127.0.0.1:(\d+)!.match(@events.stdout.string) + m = %r!http://127.0.0.1:(\d+)!.match(@events.stdout.string) port = m[1].to_i refute_equal 0, port @@ -84,9 +84,9 @@ class TestBinder < TestBinderBase def test_logs_all_localhost_bindings @binder.parse ["tcp://localhost:0"], @events - assert_match %r!tcp://127.0.0.1:(\d+)!, @events.stdout.string + assert_match %r!http://127.0.0.1:(\d+)!, @events.stdout.string if Socket.ip_address_list.any? {|i| i.ipv6_loopback? } - assert_match %r!tcp://\[::1\]:(\d+)!, @events.stdout.string + assert_match %r!http://\[::1\]:(\d+)!, @events.stdout.string end end @@ -271,7 +271,7 @@ class TestBinder < TestBinderBase prepared_paths = { ssl: "ssl://127.0.0.1:#{UniquePort.call}?#{ssl_query}", - tcp: "tcp://127.0.0.1:#{UniquePort.call}", + tcp: "http://127.0.0.1:#{UniquePort.call}", unix: "unix://test/#{name}_server.sock" }