diff --git a/lib/net/http/persistent.rb b/lib/net/http/persistent.rb index 5452fbb..46eefb1 100644 --- a/lib/net/http/persistent.rb +++ b/lib/net/http/persistent.rb @@ -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 diff --git a/test/test_net_http_persistent.rb b/test/test_net_http_persistent.rb index 0f2bde2..fc90e90 100644 --- a/test/test_net_http_persistent.rb +++ b/test/test_net_http_persistent.rb @@ -116,6 +116,9 @@ def proxy_address end def proxy_port end + def proxy? + false + end end def basic_connection