summaryrefslogtreecommitdiff
path: root/spec/bundler/support
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2023-10-22 13:25:07 -0700
committergit <svn-admin@ruby-lang.org>2023-11-15 08:33:14 +0000
commitb69bbf588a3dd167d62dbb89f0cef25ebae4a7ea (patch)
tree613203d44c4b91ee854e006b5f1cae705df75403 /spec/bundler/support
parent536649f819ed8f2bb0f8f44b1a0ca5c6d1753b24 (diff)
[rubygems/rubygems] User bundler UA when downloading gems
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 https://github.com/rubygems/rubygems/commit/f0e8dacdec
Diffstat (limited to 'spec/bundler/support')
-rw-r--r--spec/bundler/support/artifice/endpoint_mirror_source.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/spec/bundler/support/artifice/endpoint_mirror_source.rb b/spec/bundler/support/artifice/endpoint_mirror_source.rb
index 6ea1a77eca..fed7a746b9 100644
--- a/spec/bundler/support/artifice/endpoint_mirror_source.rb
+++ b/spec/bundler/support/artifice/endpoint_mirror_source.rb
@@ -4,7 +4,7 @@ require_relative "helpers/endpoint"
class EndpointMirrorSource < Endpoint
get "/gems/:id" do
- if request.env["HTTP_X_GEMFILE_SOURCE"] == "https://server.example.org/"
+ if request.env["HTTP_X_GEMFILE_SOURCE"] == "https://server.example.org/" && request.env["HTTP_USER_AGENT"].start_with?("bundler")
File.binread("#{gem_repo1}/gems/#{params[:id]}")
else
halt 500