diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-25 10:13:50 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-25 10:13:50 +0000 |
commit | d478c7a7342478847cc1148f4134b5f0db04e1d9 (patch) | |
tree | 3bfca425683a94d1360ecdf5857d741b8eaac213 /lib/rubygems/remote_fetcher.rb | |
parent | 788001a9c8473130bd357846785838045387b060 (diff) | |
download | ruby-d478c7a7342478847cc1148f4134b5f0db04e1d9.tar.gz |
Update to RubyGems 1.3.0 r1891
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/remote_fetcher.rb')
-rw-r--r-- | lib/rubygems/remote_fetcher.rb | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index 3c747f1d65..1570740163 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -78,7 +78,7 @@ class Gem::RemoteFetcher if File.writable?(install_dir) cache_dir = File.join install_dir, 'cache' else - cache_dir = File.join(ENV['HOME'], '.gem', 'cache') + cache_dir = File.join(Gem.user_dir, 'cache') end gem_file_name = "#{spec.full_name}.gem" @@ -93,7 +93,7 @@ class Gem::RemoteFetcher scheme = nil if scheme =~ /^[a-z]$/i case scheme - when 'http' then + when 'http', 'https' then unless File.exist? local_gem_path then begin say "Downloading gem #{gem_file_name}" if @@ -139,8 +139,8 @@ class Gem::RemoteFetcher # Downloads +uri+ and returns it as a String. def fetch_path(uri, mtime = nil, head = false) - data = open_uri_or_path(uri, mtime, head) - data = Gem.gunzip data if uri.to_s =~ /gz$/ and not head + data = open_uri_or_path uri, mtime, head + data = Gem.gunzip data if data and not head and uri.to_s =~ /gz$/ data rescue FetchError raise @@ -216,8 +216,9 @@ class Gem::RemoteFetcher connection = @connections[connection_id] if uri.scheme == 'https' and not connection.started? then - http_obj.use_ssl = true - http_obj.verify_mode = OpenSSL::SSL::VERIFY_NONE + require 'net/https' + connection.use_ssl = true + connection.verify_mode = OpenSSL::SSL::VERIFY_NONE end connection.start unless connection.started? @@ -241,9 +242,10 @@ class Gem::RemoteFetcher response = request uri, fetch_type, last_modified case response - when Net::HTTPOK then + when Net::HTTPOK, Net::HTTPNotModified then head ? response : response.body - when Net::HTTPRedirection then + when Net::HTTPMovedPermanently, Net::HTTPFound, Net::HTTPSeeOther, + Net::HTTPTemporaryRedirect then raise FetchError.new('too many redirects', uri) if depth > 10 open_uri_or_path(response['Location'], last_modified, head, depth + 1) @@ -274,6 +276,7 @@ class Gem::RemoteFetcher request.add_field 'Keep-Alive', '30' if last_modified then + last_modified = last_modified.utc request.add_field 'If-Modified-Since', last_modified.rfc2822 end @@ -282,9 +285,6 @@ class Gem::RemoteFetcher retried = false bad_response = false - # HACK work around EOFError bug in Net::HTTP - # NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible - # to install gems. begin @requests[connection.object_id] += 1 response = connection.request request @@ -297,6 +297,9 @@ class Gem::RemoteFetcher bad_response = true retry + # HACK work around EOFError bug in Net::HTTP + # NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible + # to install gems. rescue EOFError, Errno::ECONNABORTED, Errno::ECONNRESET requests = @requests[connection.object_id] say "connection reset after #{requests} requests, retrying" if |