diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2023-01-29 21:28:29 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-12-13 12:16:55 +0900 |
commit | 90317472e87692fff1c864d129d60130dc3bab2c (patch) | |
tree | 698f2aa5911cc1a4512c9019b6e785495c47d3bc /spec/bundler/support/artifice/helpers | |
parent | ce924ce1fb029f19fd34a43f2012a485f4f62b53 (diff) |
[rubygems/rubygems] Use vendored net-http in Bundler
https://github.com/rubygems/rubygems/commit/0d758e8926
Diffstat (limited to 'spec/bundler/support/artifice/helpers')
-rw-r--r-- | spec/bundler/support/artifice/helpers/artifice.rb | 6 | ||||
-rw-r--r-- | spec/bundler/support/artifice/helpers/rack_request.rb | 22 |
2 files changed, 14 insertions, 14 deletions
diff --git a/spec/bundler/support/artifice/helpers/artifice.rb b/spec/bundler/support/artifice/helpers/artifice.rb index b8c78614fb..788268295c 100644 --- a/spec/bundler/support/artifice/helpers/artifice.rb +++ b/spec/bundler/support/artifice/helpers/artifice.rb @@ -4,7 +4,7 @@ module Artifice # Activate Artifice with a particular Rack endpoint. # - # Calling this method will replace the Net::HTTP system + # Calling this method will replace the Gem::Net::HTTP system # with a replacement that routes all requests to the # Rack endpoint. # @@ -18,11 +18,11 @@ module Artifice # Deactivate the Artifice replacement. def self.deactivate - replace_net_http(::Net::HTTP) + replace_net_http(::Gem::Net::HTTP) end def self.replace_net_http(value) - ::Net.class_eval do + ::Gem::Net.class_eval do remove_const(:HTTP) const_set(:HTTP, value) end diff --git a/spec/bundler/support/artifice/helpers/rack_request.rb b/spec/bundler/support/artifice/helpers/rack_request.rb index 45023dfdd6..f419bacb8c 100644 --- a/spec/bundler/support/artifice/helpers/rack_request.rb +++ b/spec/bundler/support/artifice/helpers/rack_request.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "rack/test" -require "net/http" +require "bundler/vendored_net_http" module Artifice module Net @@ -16,25 +16,25 @@ module Artifice end end - class HTTP < ::Net::HTTP + class HTTP < ::Gem::Net::HTTP class << self attr_accessor :endpoint end - # Net::HTTP uses a @newimpl instance variable to decide whether + # Gem::Net::HTTP uses a @newimpl instance variable to decide whether # to use a legacy implementation. Since we are subclassing - # Net::HTTP, we must set it + # Gem::Net::HTTP, we must set it @newimpl = true # We don't need to connect, so blank out this method def connect end - # Replace the Net::HTTP request method with a method + # Replace the Gem::Net::HTTP request method with a method # that converts the request into a Rack request and # dispatches it to the Rack endpoint. # - # @param [Net::HTTPRequest] req A Net::HTTPRequest + # @param [Net::HTTPRequest] req A Gem::Net::HTTPRequest # object, or one if its subclasses # @param [optional, String, #read] body This should # be sent as "rack.input". If it's a String, it will @@ -42,7 +42,7 @@ module Artifice # @return [Net::HTTPResponse] # # @yield [Net::HTTPResponse] If a block is provided, - # this method will yield the Net::HTTPResponse to + # this method will yield the Gem::Net::HTTPResponse to # it after the body is read. def request(req, body = nil, &block) rack_request = RackRequest.new(self.class.endpoint) @@ -63,10 +63,10 @@ module Artifice private - # This method takes a Rack response and creates a Net::HTTPResponse + # This method takes a Rack response and creates a Gem::Net::HTTPResponse # Instead of trying to mock HTTPResponse directly, we just convert # the Rack response into a String that looks like a normal HTTP - # response and call Net::HTTPResponse.read_new + # response and call Gem::Net::HTTPResponse.read_new # # @param [Array(#to_i, Hash, #each)] response a Rack response # @return [Net::HTTPResponse] @@ -86,8 +86,8 @@ module Artifice response_string << "" << body - response_io = ::Net::BufferedIO.new(StringIO.new(response_string.join("\n"))) - res = ::Net::HTTPResponse.read_new(response_io) + response_io = ::Gem::Net::BufferedIO.new(StringIO.new(response_string.join("\n"))) + res = ::Gem::Net::HTTPResponse.read_new(response_io) res.reading_body(response_io, true) do yield res if block_given? |