method
fetch
v2_6_3 -
Show latest stable
-
0 notes -
Class: Downloader
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3 (0)
- What's this?
fetch(uri, headers = {}, counter = 0)
public
Hide source
# File lib/bundler/fetcher/downloader.rb, line 14 def fetch(uri, headers = {}, counter = 0) raise HTTPError, "Too many redirects" if counter >= redirect_limit response = request(uri, headers) Bundler.ui.debug("HTTP #{response.code} #{response.message} #{uri}") case response when Net::HTTPSuccess, Net::HTTPNotModified response when Net::HTTPRedirection new_uri = URI.parse(response["location"]) if new_uri.host == uri.host new_uri.user = uri.user new_uri.password = uri.password end fetch(new_uri, headers, counter + 1) when Net::HTTPRequestedRangeNotSatisfiable new_headers = headers.dup new_headers.delete("Range") new_headers["Accept-Encoding"] = "gzip" fetch(uri, new_headers) when Net::HTTPRequestEntityTooLarge raise FallbackError, response.body when Net::HTTPUnauthorized raise AuthenticationRequiredError, uri.host when Net::HTTPNotFound raise FallbackError, "Net::HTTPNotFound" else raise HTTPError, "#{response.class}#{": #{response.body}" unless response.body.empty?}" end end