summaryrefslogtreecommitdiff
path: root/test/net
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-21 19:07:28 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-21 19:07:28 +0000
commit478d37da053f39608fa505991aa69bcff4ade998 (patch)
tree3abf3cde1f69d8ef0e5d66ee71adfcce9bdead43 /test/net
parente2f75afbfb5e6f156fad47b29979778dd4a47676 (diff)
Use 0 for webrick's port and get the actual port. [Bug #6766]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net')
-rw-r--r--test/net/http/test_http.rb10
-rw-r--r--test/net/http/utils.rb5
2 files changed, 9 insertions, 6 deletions
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb
index 4867acf737..fc7bfa9806 100644
--- a/test/net/http/test_http.rb
+++ b/test/net/http/test_http.rb
@@ -616,7 +616,7 @@ end
class TestNetHTTP_v1_2 < Test::Unit::TestCase
CONFIG = {
'host' => '127.0.0.1',
- 'port' => 10081,
+ 'port' => 0,
'proxy_host' => nil,
'proxy_port' => nil,
}
@@ -634,7 +634,7 @@ end
class TestNetHTTP_v1_2_chunked < Test::Unit::TestCase
CONFIG = {
'host' => '127.0.0.1',
- 'port' => 10081,
+ 'port' => 0,
'proxy_host' => nil,
'proxy_port' => nil,
'chunked' => true,
@@ -665,7 +665,7 @@ end
class TestNetHTTPContinue < Test::Unit::TestCase
CONFIG = {
'host' => '127.0.0.1',
- 'port' => 10081,
+ 'port' => 0,
'proxy_host' => nil,
'proxy_port' => nil,
'chunked' => true,
@@ -750,7 +750,7 @@ end
class TestNetHTTPKeepAlive < Test::Unit::TestCase
CONFIG = {
'host' => '127.0.0.1',
- 'port' => 10081,
+ 'port' => 0,
'proxy_host' => nil,
'proxy_port' => nil,
'RequestTimeout' => 1,
@@ -802,7 +802,7 @@ end
class TestNetHTTPLocalBind < Test::Unit::TestCase
CONFIG = {
'host' => 'localhost',
- 'port' => 10081,
+ 'port' => 0,
'proxy_host' => nil,
'proxy_port' => nil,
}
diff --git a/test/net/http/utils.rb b/test/net/http/utils.rb
index 07e0b9fa2d..9bea8f5474 100644
--- a/test/net/http/utils.rb
+++ b/test/net/http/utils.rb
@@ -19,7 +19,8 @@ module TestNetHTTPUtils
end
def config(key)
- self.class::CONFIG[key]
+ @config ||= self.class::CONFIG
+ @config[key]
end
def logfile
@@ -42,6 +43,7 @@ module TestNetHTTPUtils
end
def spawn_server
+ @config = self.class::CONFIG
server_config = {
:BindAddress => config('host'),
:Port => config('port'),
@@ -62,6 +64,7 @@ module TestNetHTTPUtils
@server = WEBrick::HTTPServer.new(server_config)
@server.mount('/', Servlet, config('chunked'))
@server.start
+ @config['port'] = @server[:Port] if @config['port'] == 0
n_try_max = 5
begin
TCPSocket.open(config('host'), config('port')).close