summaryrefslogtreecommitdiff
path: root/lib/rubygems/request/connection_pools.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-01 21:50:14 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-01 21:50:14 +0000
commiteffdbf5936cc090a618e13c8f9a1b5412ebab2fa (patch)
treec8410a18cbbe7ad013470fc06fef0c75ce0fd230 /lib/rubygems/request/connection_pools.rb
parent9c4ef4b191a1e6b9abdbb21c7c709d1d0f2397e6 (diff)
* lib/rubygems: Update to RubyGems HEAD(c202db2).
this version contains many enhancements see http://git.io/vtNwF * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/request/connection_pools.rb')
-rw-r--r--lib/rubygems/request/connection_pools.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/rubygems/request/connection_pools.rb b/lib/rubygems/request/connection_pools.rb
index 7a0a6e6e74..271b32b2b1 100644
--- a/lib/rubygems/request/connection_pools.rb
+++ b/lib/rubygems/request/connection_pools.rb
@@ -61,18 +61,22 @@ class Gem::Request::ConnectionPools # :nodoc:
end
def net_http_args uri, proxy_uri
- net_http_args = [uri.host, uri.port]
+ # URI::Generic#hostname was added in ruby 1.9.3, use it if exists, otherwise
+ # don't support IPv6 literals and use host.
+ hostname = uri.respond_to?(:hostname) ? uri.hostname : uri.host
+ net_http_args = [hostname, uri.port]
no_proxy = get_no_proxy_from_env
- if proxy_uri and not no_proxy?(uri.host, no_proxy) then
+ if proxy_uri and not no_proxy?(hostname, no_proxy) then
+ proxy_hostname = proxy_uri.respond_to?(:hostname) ? proxy_uri.hostname : proxy_uri.host
net_http_args + [
- proxy_uri.host,
+ proxy_hostname,
proxy_uri.port,
Gem::UriFormatter.new(proxy_uri.user).unescape,
Gem::UriFormatter.new(proxy_uri.password).unescape,
]
- elsif no_proxy? uri.host, no_proxy then
+ elsif no_proxy? hostname, no_proxy then
net_http_args + [nil, nil]
else
net_http_args