mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/net/http.rb: More descriptive error message when net/http fails
to connect to a server. Patch by @xaviershay [fix GH-700] * test/net/http/test_http.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2758be26bb
commit
a84bfcbf00
3 changed files with 21 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
Sat Jan 3 10:38:52 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
||||
|
||||
* lib/net/http.rb: More descriptive error message when net/http fails
|
||||
to connect to a server. Patch by @xaviershay [fix GH-700]
|
||||
* test/net/http/test_http.rb: ditto.
|
||||
|
||||
Sat Jan 3 10:14:51 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
||||
|
||||
* ext/openssl/ossl.h: Make `SSL_SESSION_cmp` use `CRYPTO_memcmp`
|
||||
|
|
|
@ -876,7 +876,12 @@ module Net #:nodoc:
|
|||
|
||||
D "opening connection to #{conn_address}:#{conn_port}..."
|
||||
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {
|
||||
begin
|
||||
TCPSocket.open(conn_address, conn_port, @local_host, @local_port)
|
||||
rescue => e
|
||||
raise e, "Failed to open TCP connection to " +
|
||||
"#{conn_address}:#{conn_port} (#{e.message})"
|
||||
end
|
||||
}
|
||||
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||
D "opened"
|
||||
|
|
|
@ -188,6 +188,15 @@ class TestNetHTTP < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_failure_message_includes_failed_domain_and_port
|
||||
begin
|
||||
Net::HTTP.get(URI.parse("http://doesnotexist.bogus"))
|
||||
fail "should have raised"
|
||||
rescue => e
|
||||
assert_includes e.message, "doesnotexist.bogus:80"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module TestNetHTTP_version_1_1_methods
|
||||
|
|
Loading…
Reference in a new issue