From 04d7415f7b9c6bb37a7d21bc9b7f35367e2e84e4 Mon Sep 17 00:00:00 2001 From: Alex Leaver Date: Thu, 5 Feb 2026 13:17:31 +0000 Subject: [PATCH] Log URL with correct protocol in Net::HTTP requests Previously URLs were always logged with "http://" even if the connection was made over SSL. --- lib/httplog/adapters/net_http.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/httplog/adapters/net_http.rb b/lib/httplog/adapters/net_http.rb index 3b0317d..168cc7f 100644 --- a/lib/httplog/adapters/net_http.rb +++ b/lib/httplog/adapters/net_http.rb @@ -6,7 +6,7 @@ class HTTP alias orig_connect connect unless method_defined?(:orig_connect) def request(req, body = nil, &block) - url = "http://#{@address}:#{@port}#{req.path}" + url = "#{protocol}://#{@address}:#{@port}#{req.path}" bm = Benchmark.realtime do @response = orig_request(req, body, &block) @@ -46,5 +46,11 @@ def connect orig_connect end + + private + + def protocol + use_ssl? ? 'https' : 'http' + end end end