mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Host header should add branckets to IPv6 address [Bug #12642]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f56288d7a8
commit
3acc0ba1d8
2 changed files with 31 additions and 5 deletions
|
@ -1612,11 +1612,10 @@ module Net #:nodoc:
|
|||
private
|
||||
|
||||
def addr_port
|
||||
if use_ssl?
|
||||
address() + (port == HTTP.https_default_port ? '' : ":#{port()}")
|
||||
else
|
||||
address() + (port == HTTP.http_default_port ? '' : ":#{port()}")
|
||||
end
|
||||
addr = address
|
||||
addr = "[#{addr}]" if addr.include?(":")
|
||||
default_port = use_ssl? ? HTTP.https_default_port : HTTP.http_default_port
|
||||
default_port == port ? addr : "#{addr}:#{port}"
|
||||
end
|
||||
|
||||
def D(msg)
|
||||
|
|
|
@ -59,6 +59,33 @@ class TestNetHTTP < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_addr_port
|
||||
http = Net::HTTP.new 'hostname.example', nil, nil
|
||||
addr_port = http.__send__ :addr_port
|
||||
assert_equal 'hostname.example', addr_port
|
||||
|
||||
http.use_ssl = true
|
||||
addr_port = http.__send__ :addr_port
|
||||
assert_equal 'hostname.example:80', addr_port
|
||||
|
||||
http = Net::HTTP.new '203.0.113.1', nil, nil
|
||||
addr_port = http.__send__ :addr_port
|
||||
assert_equal '203.0.113.1', addr_port
|
||||
|
||||
http.use_ssl = true
|
||||
addr_port = http.__send__ :addr_port
|
||||
assert_equal '203.0.113.1:80', addr_port
|
||||
|
||||
http = Net::HTTP.new '2001:db8::1', nil, nil
|
||||
addr_port = http.__send__ :addr_port
|
||||
assert_equal '[2001:db8::1]', addr_port
|
||||
|
||||
http.use_ssl = true
|
||||
addr_port = http.__send__ :addr_port
|
||||
assert_equal '[2001:db8::1]:80', addr_port
|
||||
|
||||
end
|
||||
|
||||
def test_edit_path
|
||||
http = Net::HTTP.new 'hostname.example', nil, nil
|
||||
|
||||
|
|
Loading…
Reference in a new issue