summaryrefslogtreecommitdiff
path: root/lib/rubygems/remote_fetcher.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-04 00:48:31 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-04 00:48:31 +0000
commitea2a00d785576a7dc45c0f6e965de605929e889d (patch)
tree567e52888b17aacb404c59eb64519d927fb8894f /lib/rubygems/remote_fetcher.rb
parentbd950a75b512a7d6243d1f0bb5e944a06a2e1f94 (diff)
* lib/rubygems: Update to RubyGems 2.2.2 prerelease to check fixes to
CI. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/remote_fetcher.rb')
-rw-r--r--lib/rubygems/remote_fetcher.rb40
1 files changed, 24 insertions, 16 deletions
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index e32c024989..58991caeda 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -131,11 +131,19 @@ class Gem::RemoteFetcher
FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
- # Always escape URI's to deal with potential spaces and such
- unless URI::Generic === source_uri
- source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ?
- URI::DEFAULT_PARSER.escape(source_uri.to_s) :
- URI.escape(source_uri.to_s))
+ # Always escape URI's to deal with potential spaces and such
+ # It should also be considered that source_uri may already be
+ # a valid URI with escaped characters. e.g. "{DESede}" is encoded
+ # as "%7BDESede%7D". If this is escaped again the percentage
+ # symbols will be escaped.
+ unless source_uri.is_a?(URI::Generic)
+ begin
+ source_uri = URI.parse(source_uri)
+ rescue
+ source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ?
+ URI::DEFAULT_PARSER.escape(source_uri.to_s) :
+ URI.escape(source_uri.to_s))
+ end
end
scheme = source_uri.scheme
@@ -285,20 +293,20 @@ class Gem::RemoteFetcher
def cache_update_path uri, path = nil, update = true
mtime = path && File.stat(path).mtime rescue nil
- if mtime && Net::HTTPNotModified === fetch_path(uri, mtime, true)
- Gem.read_binary(path)
- else
- data = fetch_path(uri)
+ data = fetch_path(uri, mtime)
- if update and path then
- open(path, 'wb') do |io|
- io.flock(File::LOCK_EX)
- io.write data
- end
- end
+ if data == nil # indicates the server returned 304 Not Modified
+ return Gem.read_binary(path)
+ end
- data
+ if update and path
+ open(path, 'wb') do |io|
+ io.flock(File::LOCK_EX)
+ io.write data
+ end
end
+
+ data
end
##