aboutsummaryrefslogtreecommitdiffstats
path: root/test/net
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-21 15:45:10 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-21 15:45:10 +0000
commit07a6d0e9d112db7276492bcaf0856e04399232c1 (patch)
treecd5bda2fea60bcae2445788e7910a72a7adfed45 /test/net
parent36c45154d609e97f45ea1fca2477d9675f414616 (diff)
downloadruby-07a6d0e9d112db7276492bcaf0856e04399232c1.tar.gz
* lib/net/http.rb (Net::HTTP.newobj): return back for compatibility.
* lib/net/http.rb (Net::HTTP.new): set default_port if proxy port is not given. * lib/net/http.rb (Net::HTTP#initialize): ditto. * lib/net/http.rb (Net::HTTP#proxy?): return true or false. * lib/net/http.rb (Net::HTTP#proxy_address): check proxy_uri is not nil. * lib/net/http.rb (Net::HTTP#proxy_port): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net')
-rw-r--r--test/net/http/test_http.rb33
1 files changed, 27 insertions, 6 deletions
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb
index df71c2add9..4867acf737 100644
--- a/test/net/http/test_http.rb
+++ b/test/net/http/test_http.rb
@@ -26,6 +26,11 @@ class TestNetHTTP < Test::Unit::TestCase
http = proxy_class.new 'example'
refute http.proxy_from_env?
+
+
+ proxy_class = Net::HTTP.Proxy 'proxy.example'
+ assert_equal 'proxy.example', proxy_class.proxy_address
+ assert_equal 80, proxy_class.proxy_port
end
def test_class_Proxy_from_ENV
@@ -84,8 +89,10 @@ class TestNetHTTP < Test::Unit::TestCase
def test_proxy_address
http = Net::HTTP.new 'example', nil, 'proxy.example'
-
assert_equal 'proxy.example', http.proxy_address
+
+ http = Net::HTTP.new 'example', nil
+ assert_equal nil, http.proxy_address
end
def test_proxy_address_ENV
@@ -100,7 +107,7 @@ class TestNetHTTP < Test::Unit::TestCase
def test_proxy_eh_no_proxy
clean_http_proxy_env do
- refute Net::HTTP.new('example', nil, nil).proxy?
+ assert_equal false, Net::HTTP.new('example', nil, nil).proxy?
end
end
@@ -110,13 +117,13 @@ class TestNetHTTP < Test::Unit::TestCase
http = Net::HTTP.new 'example'
- assert http.proxy?
+ assert_equal true, http.proxy?
end
end
def test_proxy_eh_ENV_none_set
clean_http_proxy_env do
- refute Net::HTTP.new('example').proxy?
+ assert_equal false, Net::HTTP.new('example').proxy?
end
end
@@ -125,14 +132,18 @@ class TestNetHTTP < Test::Unit::TestCase
ENV['http_proxy'] = 'http://proxy.example:8000'
ENV['no_proxy'] = 'example'
- refute Net::HTTP.new('example').proxy?
+ assert_equal false, Net::HTTP.new('example').proxy?
end
end
def test_proxy_port
+ http = Net::HTTP.new 'exmaple', nil, 'proxy.example'
+ assert_equal 'proxy.example', http.proxy_address
+ assert_equal 80, http.proxy_port
http = Net::HTTP.new 'exmaple', nil, 'proxy.example', 8000
-
assert_equal 8000, http.proxy_port
+ http = Net::HTTP.new 'exmaple', nil
+ assert_equal nil, http.proxy_port
end
def test_proxy_port_ENV
@@ -145,6 +156,16 @@ class TestNetHTTP < Test::Unit::TestCase
end
end
+ def test_newobj
+ clean_http_proxy_env do
+ ENV['http_proxy'] = 'http://proxy.example:8000'
+
+ http = Net::HTTP.newobj 'example'
+
+ assert_equal false, http.proxy?
+ end
+ end
+
def clean_http_proxy_env
orig = {
'http_proxy' => ENV['http_proxy'],