diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-18 21:29:41 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-18 21:29:41 +0000 |
commit | 95683e5cb2d1ab8351402b09ef853dcdf875bf8d (patch) | |
tree | 44500dba22e9aa94ecc5d4fd348512d0fb236501 /lib/rubygems/request.rb | |
parent | 81629f05312cc4df2193a17f13c581eda174d9af (diff) | |
download | ruby-95683e5cb2d1ab8351402b09ef853dcdf875bf8d.tar.gz |
* lib/rubygems: Update to RubyGems 2.2.0.preview.1
This brings several new features to RubyGems summarized here:
https://github.com/rubygems/rubygems/blob/v2.2.0.preview.1/History.txt
* test/rubygems: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/request.rb')
-rw-r--r-- | lib/rubygems/request.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb index b2e9dbc679..00407971dd 100644 --- a/lib/rubygems/request.rb +++ b/lib/rubygems/request.rb @@ -21,7 +21,7 @@ class Gem::Request @proxy_uri = case proxy when :no_proxy then nil - when nil then get_proxy_from_env + when nil then get_proxy_from_env uri.scheme when URI::HTTP then proxy else URI.parse(proxy) end @@ -203,19 +203,27 @@ class Gem::Request end ## - # Returns an HTTP proxy URI if one is set in the environment variables. + # Returns a proxy URI for the given +scheme+ if one is set in the + # environment variables. - def get_proxy_from_env - env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] + def get_proxy_from_env scheme = 'http' + _scheme = scheme.downcase + _SCHEME = scheme.upcase + env_proxy = ENV["#{_scheme}_proxy"] || ENV["#{_SCHEME}_PROXY"] - return nil if env_proxy.nil? or env_proxy.empty? + no_env_proxy = env_proxy.nil? || env_proxy.empty? + + return get_proxy_from_env 'http' if no_env_proxy and _scheme != 'http' + return nil if no_env_proxy uri = URI(Gem::UriFormatter.new(env_proxy).normalize) if uri and uri.user.nil? and uri.password.nil? then - # Probably we have http_proxy_* variables? - uri.user = Gem::UriFormatter.new(ENV['http_proxy_user'] || ENV['HTTP_PROXY_USER']).escape - uri.password = Gem::UriFormatter.new(ENV['http_proxy_pass'] || ENV['HTTP_PROXY_PASS']).escape + user = ENV["#{_scheme}_proxy_user"] || ENV["#{_SCHEME}_PROXY_USER"] + password = ENV["#{_scheme}_proxy_pass"] || ENV["#{_SCHEME}_PROXY_PASS"] + + uri.user = Gem::UriFormatter.new(user).escape + uri.password = Gem::UriFormatter.new(password).escape end uri |