Skip to content

Commit

Permalink
Merge pull request #146 from kmcphillips/master
Browse files Browse the repository at this point in the history
Show correct port and address in connection exception messages
  • Loading branch information
tenderlove authored Nov 3, 2023
2 parents c1fb1a5 + 9cdc7bf commit 12a9230
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/net/http/persistent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -612,13 +612,23 @@ def connection_for uri

return yield connection
rescue Errno::ECONNREFUSED
address = http.proxy_address || http.address
port = http.proxy_port || http.port
if http.proxy?
address = http.proxy_address
port = http.proxy_port
else
address = http.address
port = http.port
end

raise Error, "connection refused: #{address}:#{port}"
rescue Errno::EHOSTDOWN
address = http.proxy_address || http.address
port = http.proxy_port || http.port
if http.proxy?
address = http.proxy_address
port = http.proxy_port
else
address = http.address
port = http.port
end

raise Error, "host down: #{address}:#{port}"
ensure
Expand Down
3 changes: 3 additions & 0 deletions test/test_net_http_persistent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def proxy_address
end
def proxy_port
end
def proxy?
false
end
end

def basic_connection
Expand Down

0 comments on commit 12a9230

Please sign in to comment.