mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 13:34:17 +02:00

Gem::RemoteFetcher uses Gem::Request, which adds the RubyGems UA.
Gem::RemoteFetcher is used to download gems, as well as the full index.
We would like the bundler UA to be used whenever bundler is making
requests.
This PR also avoids unsafely mutating the headers hash on the shared
`Gem::RemoteFetcher.fetcher` instance, which could cause corruption or
incorrect headers when making parallel requests. Instead, we create one
remote fetcher per rubygems remote, which is similar to the connection
segregation bundler is already doing
f0e8dacdec
16 lines
329 B
Ruby
16 lines
329 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rubygems/remote_fetcher"
|
|
|
|
module Bundler
|
|
class Fetcher
|
|
class GemRemoteFetcher < Gem::RemoteFetcher
|
|
def request(*args)
|
|
super do |req|
|
|
req.delete("User-Agent") if headers["User-Agent"]
|
|
yield req if block_given?
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|