From 5335ce0e060c7a2a0b01c57f8f8a64254f2658e1 Mon Sep 17 00:00:00 2001 From: hsbt Date: Wed, 21 Nov 2018 10:20:47 +0000 Subject: Merge master branch from rubygems/rubygems upstream. * Enable Style/MethodDefParentheses in Rubocop https://github.com/rubygems/rubygems/pull/2478 * Enable Style/MultilineIfThen in Rubocop https://github.com/rubygems/rubygems/pull/2479 * Fix required_ruby_version with prereleases and improve error message https://github.com/rubygems/rubygems/pull/2344 * Fix bundler rubygems binstub not properly looking for bundler https://github.com/rubygems/rubygems/pull/2426 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/request/connection_pools.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lib/rubygems/request/connection_pools.rb') diff --git a/lib/rubygems/request/connection_pools.rb b/lib/rubygems/request/connection_pools.rb index f95dd8aabf..c02f083b63 100644 --- a/lib/rubygems/request/connection_pools.rb +++ b/lib/rubygems/request/connection_pools.rb @@ -8,19 +8,19 @@ class Gem::Request::ConnectionPools # :nodoc: attr_accessor :client end - def initialize proxy_uri, cert_files + def initialize(proxy_uri, cert_files) @proxy_uri = proxy_uri @cert_files = cert_files @pools = {} @pool_mutex = Mutex.new end - def pool_for uri + def pool_for(uri) http_args = net_http_args(uri, @proxy_uri) key = http_args + [https?(uri)] @pool_mutex.synchronize do @pools[key] ||= - if https? uri then + if https? uri Gem::Request::HTTPSPool.new(http_args, @cert_files, @proxy_uri) else Gem::Request::HTTPPool.new(http_args, @cert_files, @proxy_uri) @@ -45,11 +45,11 @@ class Gem::Request::ConnectionPools # :nodoc: env_no_proxy.split(/\s*,\s*/) end - def https? uri + def https?(uri) uri.scheme.downcase == 'https' end - def no_proxy? host, env_no_proxy + def no_proxy?(host, env_no_proxy) host = host.downcase env_no_proxy.any? do |pattern| @@ -73,7 +73,7 @@ class Gem::Request::ConnectionPools # :nodoc: end end - def net_http_args uri, proxy_uri + def net_http_args(uri, proxy_uri) # 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 @@ -81,7 +81,7 @@ class Gem::Request::ConnectionPools # :nodoc: no_proxy = get_no_proxy_from_env - if proxy_uri and not no_proxy?(hostname, no_proxy) then + if proxy_uri and not no_proxy?(hostname, no_proxy) proxy_hostname = proxy_uri.respond_to?(:hostname) ? proxy_uri.hostname : proxy_uri.host net_http_args + [ proxy_hostname, @@ -89,7 +89,7 @@ class Gem::Request::ConnectionPools # :nodoc: Gem::UriFormatter.new(proxy_uri.user).unescape, Gem::UriFormatter.new(proxy_uri.password).unescape, ] - elsif no_proxy? hostname, no_proxy then + elsif no_proxy? hostname, no_proxy net_http_args + [nil, nil] else net_http_args @@ -97,4 +97,3 @@ class Gem::Request::ConnectionPools # :nodoc: end end - -- cgit v1.2.3