method
fetch_path
v2_6_3 -
Show latest stable
- Class:
Gem::RemoteFetcher
fetch_path(uri, mtime = nil, head = false)public
Downloads uri and returns it as a String.
# File lib/rubygems/remote_fetcher.rb, line 253
def fetch_path(uri, mtime = nil, head = false)
uri = URI.parse uri unless URI::Generic === uri
raise ArgumentError, "bad uri: #{uri}" unless uri
unless uri.scheme
raise ArgumentError, "uri scheme is invalid: #{uri.scheme.inspect}"
end
data = send "fetch_#{uri.scheme}", uri, mtime, head
if data and !head and uri.to_s =~ /\.gz$/
begin
data = Gem::Util.gunzip data
rescue Zlib::GzipFile::Error
raise FetchError.new("server did not return a valid file", uri.to_s)
end
end
data
rescue FetchError
raise
rescue Timeout::Error
raise UnknownHostError.new('timed out', uri.to_s)
rescue IOError, SocketError, SystemCallError,
*(OpenSSL::SSL::SSLError if defined?(OpenSSL)) => e
if e.message =~ /getaddrinfo/
raise UnknownHostError.new('no such name', uri.to_s)
else
raise FetchError.new("#{e.class}: #{e}", uri.to_s)
end
end Related methods
- Instance methods
- cache_update_path
- close_all
- correct_for_windows_path
- download
- download_to_cache
- fetch_file
- fetch_http
- fetch_https
- fetch_path
- fetch_s3
- fetch_size
- https?
- request
- Class methods
- fetcher
- new
- Protected methods
-
s3_expiration -
sign_s3_url - Private methods
-
pools_for -
proxy_for -
s3_source_auth