1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

downloader.rb: defer warning

* tool/downloader.rb (Downloader.download): warn using http only
  when really downloading.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-02-18 07:53:13 +00:00
parent 5a6b090368
commit 38c0bdccdb

View file

@ -35,19 +35,20 @@ class Downloader
@@https = https @@https = https
end end
def self.https def self.https?
if @@https != 'https' @@https == 'https'
warn "*** using http instead of https ***"
end end
def self.https
@@https @@https
end end
class GNU < self class GNU < self
def self.download(name, *rest) def self.download(name, *rest)
if https == 'https' if https?
super("https://raw.githubusercontent.com/gcc-mirror/gcc/master/#{name}", name, *rest) super("https://raw.githubusercontent.com/gcc-mirror/gcc/master/#{name}", name, *rest)
else else
super("http://repo.or.cz/official-gcc.git/blob_plain/HEAD:/#{name}", name, *rest) super("https://repo.or.cz/official-gcc.git/blob_plain/HEAD:/#{name}", name, *rest)
end end
end end
end end
@ -58,7 +59,7 @@ class Downloader
require 'rubygems/package' require 'rubygems/package'
options[:ssl_ca_cert] = Dir.glob(File.expand_path("../lib/rubygems/ssl_certs/*.pem", File.dirname(__FILE__))) options[:ssl_ca_cert] = Dir.glob(File.expand_path("../lib/rubygems/ssl_certs/*.pem", File.dirname(__FILE__)))
file = under(dir, name) file = under(dir, name)
super("#{https}://rubygems.org/downloads/#{name}", file, nil, since, options) or super("https://rubygems.org/downloads/#{name}", file, nil, since, options) or
return false return false
policy = Gem::Security::LowSecurity policy = Gem::Security::LowSecurity
(policy = policy.dup).ui = Gem::SilentUI.new if policy.respond_to?(:'ui=') (policy = policy.dup).ui = Gem::SilentUI.new if policy.respond_to?(:'ui=')
@ -141,6 +142,10 @@ class Downloader
end end
return true return true
end end
if !https? and url.start_with?("https:")
warn "*** using http instead of https ***"
url = url.sub(/\Ahttps/, 'http')
end
url = URI(url) url = URI(url)
if $VERBOSE if $VERBOSE
$stdout.print "downloading #{name} ... " $stdout.print "downloading #{name} ... "