summaryrefslogtreecommitdiff
path: root/test/net/http
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-18 16:48:54 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-18 16:48:54 +0000
commitda78490c807186230b9af22870ba91905820cc56 (patch)
tree45dc24f266792a04d23387fd0bbf40020840dd6f /test/net/http
parent64b7aa9e2f17b2f226dd1759bc99e8c273120a8c (diff)
use localhost for both local and remote. [Bug #6746]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/http')
-rw-r--r--test/net/http/test_http.rb16
1 files changed, 4 insertions, 12 deletions
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb
index 0931133b29..3cebcb0164 100644
--- a/test/net/http/test_http.rb
+++ b/test/net/http/test_http.rb
@@ -611,7 +611,7 @@ class TestNetHTTPKeepAlive < Test::Unit::TestCase
start {|http|
assert_raises(EOFError, Errno::ECONNRESET, IOError) {
- res = http.get('/')
+ http.get('/')
}
}
end
@@ -619,7 +619,7 @@ end
class TestNetHTTPLocalBind < Test::Unit::TestCase
CONFIG = {
- 'host' => '127.0.0.1',
+ 'host' => 'localhost',
'port' => 10081,
'proxy_host' => nil,
'proxy_port' => nil,
@@ -632,7 +632,7 @@ class TestNetHTTPLocalBind < Test::Unit::TestCase
@server.mount_proc('/show_ip') { |req, res| res.body = req.remote_ip }
http = Net::HTTP.new(config('host'), config('port'))
- http.local_host = _select_local_ip_address(config('host'), config('port'))
+ http.local_host = Addrinfo.tcp(config('host'), config('port')).ip_address
assert_not_nil(http.local_host)
assert_nil(http.local_port)
@@ -645,7 +645,7 @@ class TestNetHTTPLocalBind < Test::Unit::TestCase
@server.mount_proc('/show_port') { |req, res| res.body = req.peeraddr[1].to_s }
http = Net::HTTP.new(config('host'), config('port'))
- http.local_host = _select_local_ip_address(config('host'), config('port'))
+ http.local_host = Addrinfo.tcp(config('host'), config('port')).ip_address
http.local_port = [*10000..20000].shuffle.first.to_s
assert_not_nil(http.local_host)
assert_not_nil(http.local_port)
@@ -653,12 +653,4 @@ class TestNetHTTPLocalBind < Test::Unit::TestCase
res = http.get('/show_port')
assert_equal(http.local_port, res.body)
end
-
- def _select_local_ip_address(saddr, sport)
- Socket.ip_address_list.find { |addr|
- next if Addrinfo.tcp(saddr, sport).afamily != addr.afamily
- addr.ipv4? ? !addr.ipv4_loopback? && !addr.ipv4_multicast? \
- : !addr.ipv6_loopback? && !addr.ipv6_multicast?
- }.ip_address
- end
end