diff options
author | David RodrÃguez <[email protected]> | 2023-01-29 21:24:11 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2023-12-13 12:16:55 +0900 |
commit | ce924ce1fb029f19fd34a43f2012a485f4f62b53 () | |
tree | 85a74c778127dc532651fcd303d1720c99bbaf48 /lib/rubygems/gemcutter_utilities.rb | |
parent | 6cefad77042ee3277488f56e8046c53f5313a82f (diff) |
[rubygems/rubygems] Vendor net-http and net-protocol in RubyGems
https://.com/rubygems/rubygems/commit/99d91c9ed2
-rw-r--r-- | lib/rubygems/gemcutter_utilities.rb | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -84,7 +84,7 @@ module Gem::GemcutterUtilities # If +allowed_push_host+ metadata is present, then it will only allow that host. def rubygems_api_request(method, path, host = nil, allowed_push_host = nil, scope: nil, credentials: {}, &block) - require "net/http" self.host = host if host unless self.host @@ -119,7 +119,7 @@ module Gem::GemcutterUtilities end def mfa_unauthorized?(response) - response.is_a?(Net::HTTPUnauthorized) && response.body.start_with?("You have enabled multifactor authentication") end def update_scope(scope) @@ -208,13 +208,13 @@ module Gem::GemcutterUtilities def with_response(response, error_prefix = nil) case response - when Net::HTTPSuccess then if block_given? yield response else say clean_text(response.body) end - when Net::HTTPPermanentRedirect, Net::HTTPRedirection then message = "The request has redirected permanently to #{response["location"]}. Please check your defined push host URL." message = "#{error_prefix}: #{message}" if error_prefix @@ -244,7 +244,7 @@ module Gem::GemcutterUtilities private def request_with_otp(method, uri, &block) - request_method = Net::HTTP.const_get method.to_s.capitalize Gem::RemoteFetcher.fetcher.request(uri, request_method) do |req| req["OTP"] = otp if otp @@ -297,7 +297,7 @@ module Gem::GemcutterUtilities request.basic_auth credentials[:email], credentials[:password] end end - response.is_a?(Net::HTTPSuccess) ? response.body : nil end def pretty_host(host) @@ -366,6 +366,6 @@ module Gem::GemcutterUtilities end def api_key_forbidden?(response) - response.is_a?(Net::HTTPForbidden) && response.body.start_with?("The API key doesn't have access") end end |