summaryrefslogtreecommitdiff
path: root/lib/bundler
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-12-03 16:28:32 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-12-06 23:52:40 +0100
commitae71ea0380a5ee0f7d52a6784f2a76ed46abf133 (patch)
tree18229bb09aa221ccf36bf7155b319462ad9cf157 /lib/bundler
parent34d7fa5462c50701cdae896d9cf004c050f5bfe2 (diff)
downloadbundler-ae71ea0380a5ee0f7d52a6784f2a76ed46abf133.tar.gz
Remove unnecessary code copied from rubygems
I think the comment is misleading and it referred to rubygems, not gemstash, because this code is about the client side of things. If this is correct, we can drop it because we don't support any rubygems version under 2.5.2, and the fix was introduced in rubygems 2.5.
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/gem_remote_fetcher.rb43
-rw-r--r--lib/bundler/rubygems_integration.rb2
2 files changed, 1 insertions, 44 deletions
diff --git a/lib/bundler/gem_remote_fetcher.rb b/lib/bundler/gem_remote_fetcher.rb
deleted file mode 100644
index 9577535d63..0000000000
--- a/lib/bundler/gem_remote_fetcher.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# frozen_string_literal: true
-
-require "rubygems/remote_fetcher"
-
-module Bundler
- # Adds support for setting custom HTTP headers when fetching gems from the
- # server.
- #
- # TODO: Get rid of this when and if gemstash only supports RubyGems versions
- # that contain https://github.com/rubygems/rubygems/commit/3db265cc20b2f813.
- class GemRemoteFetcher < Gem::RemoteFetcher
- attr_accessor :headers
-
- # Extracted from RubyGems 2.4.
- def fetch_http(uri, last_modified = nil, head = false, depth = 0)
- fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get
- # beginning of change
- response = request uri, fetch_type, last_modified do |req|
- headers.each {|k, v| req.add_field(k, v) } if headers
- end
- # end of change
-
- case response
- when Net::HTTPOK, Net::HTTPNotModified then
- response.uri = uri if response.respond_to? :uri
- head ? response : response.body
- when Net::HTTPMovedPermanently, Net::HTTPFound, Net::HTTPSeeOther,
- Net::HTTPTemporaryRedirect then
- raise FetchError.new("too many redirects", uri) if depth > 10
-
- location = URI.parse response["Location"]
-
- if https?(uri) && !https?(location)
- raise FetchError.new("redirecting to non-https resource: #{location}", uri)
- end
-
- fetch_http(location, last_modified, head, depth + 1)
- else
- raise FetchError.new("bad response #{response.message} #{response.code}", uri)
- end
- end
- end
-end
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 0d4dc75dbd..8a184515ed 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -533,7 +533,7 @@ module Bundler
require "resolv"
proxy = configuration[:http_proxy]
dns = Resolv::DNS.new
- Bundler::GemRemoteFetcher.new(proxy, dns)
+ Gem::RemoteFetcher.new(proxy, dns)
end
def gem_from_path(path, policy = nil)