summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2013-12-30 13:31:18 -0800
committerAndre Arko <andre@arko.net>2013-12-30 13:31:18 -0800
commitb4691a224dc7155b3cdd2a0b53e2859080890418 (patch)
treec9ef5c0b260e2446ba825a360c8033ddafd6dfeb
parentb27d2e7b5e9e9282dab203a8284f870288528a93 (diff)
downloadbundler-b4691a224dc7155b3cdd2a0b53e2859080890418.tar.gz
extract Fetcher#request
-rw-r--r--lib/bundler/fetcher.rb23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index 79853152ba..940eb4fd24 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -235,17 +235,7 @@ module Bundler
def fetch(uri, counter = 0)
raise HTTPError, "Too many redirects" if counter >= @redirect_limit
- begin
- Bundler.ui.debug "Fetching from: #{uri}"
- req = Net::HTTP::Get.new uri.request_uri
- req.basic_auth(uri.user, uri.password) if uri.user
- response = connection.request(uri, req)
- rescue OpenSSL::SSL::SSLError
- raise CertificateFailureError.new(uri)
- rescue *HTTP_ERRORS
- raise HTTPError, "Network error while fetching #{uri}"
- end
-
+ response = request(uri)
case response
when Net::HTTPRedirection
Bundler.ui.debug("HTTP Redirection")
@@ -265,6 +255,17 @@ module Bundler
end
end
+ def request(uri)
+ Bundler.ui.debug "Fetching from: #{uri}"
+ req = Net::HTTP::Get.new uri.request_uri
+ req.basic_auth(uri.user, uri.password) if uri.user
+ response = connection.request(uri, req)
+ rescue OpenSSL::SSL::SSLError
+ raise CertificateFailureError.new(uri)
+ rescue *HTTP_ERRORS
+ raise HTTPError, "Network error while fetching #{uri}"
+ end
+
def dependency_api_uri(gem_names = [])
url = "#{@remote_uri}api/v1/dependencies"
url << "?gems=#{URI.encode(gem_names.join(","))}" if gem_names.any?