diff --git a/python/lib/dependabot/python/metadata_finder.rb b/python/lib/dependabot/python/metadata_finder.rb index 6e699583598..09e7fca0120 100644 --- a/python/lib/dependabot/python/metadata_finder.rb +++ b/python/lib/dependabot/python/metadata_finder.rb @@ -5,7 +5,7 @@ require "dependabot/metadata_finders" require "dependabot/metadata_finders/base" -require "dependabot/shared_helpers" +require "dependabot/registry_client" require "dependabot/python/authed_url_builder" require "dependabot/python/name_normaliser" @@ -65,11 +65,7 @@ def source_from_description @source_from_description ||= potential_source_urls.find do |url| full_url = Source.from_url(url).url - response = Excon.get( - full_url, - idempotent: true, - **SharedHelpers.excon_defaults - ) + response = Dependabot::RegistryClient.get(url: full_url) next unless response.status == 200 response.body.include?(normalised_dependency_name) @@ -94,11 +90,7 @@ def source_from_homepage @source_from_homepage ||= potential_source_urls.find do |url| full_url = Source.from_url(url).url - response = Excon.get( - full_url, - idempotent: true, - **SharedHelpers.excon_defaults - ) + response = Dependabot::RegistryClient.get(url: full_url) next unless response.status == 200 response.body.include?(normalised_dependency_name) @@ -116,11 +108,7 @@ def homepage_body @homepage_response ||= begin - Excon.get( - homepage_url, - idempotent: true, - **SharedHelpers.excon_defaults - ) + Dependabot::RegistryClient.get(url: homepage_url) rescue Excon::Error::Timeout, Excon::Error::Socket, Excon::Error::TooManyRedirects, ArgumentError nil @@ -153,15 +141,15 @@ def fetch_authed_url(url) Regexp.last_match.captures[1].include?("@") protocol, user, pass, url = Regexp.last_match.captures - Excon.get( - "#{protocol}://#{url}", - user: user, - password: pass, - idempotent: true, - **SharedHelpers.excon_defaults + Dependabot::RegistryClient.get( + url: "#{protocol}://#{url}", + options: { + user: user, + password: pass + } ) else - Excon.get(url, idempotent: true, **SharedHelpers.excon_defaults) + Dependabot::RegistryClient.get(url: url) end end diff --git a/python/lib/dependabot/python/update_checker.rb b/python/lib/dependabot/python/update_checker.rb index f7e18f8dd0a..87064b2eee1 100644 --- a/python/lib/dependabot/python/update_checker.rb +++ b/python/lib/dependabot/python/update_checker.rb @@ -6,7 +6,7 @@ require "dependabot/dependency" require "dependabot/update_checkers" require "dependabot/update_checkers/base" -require "dependabot/shared_helpers" +require "dependabot/registry_client" require "dependabot/errors" require "dependabot/python/requirement" require "dependabot/python/requirement_parser" @@ -274,10 +274,8 @@ def poetry_library? details = TomlRB.parse(pyproject.content).dig("tool", "poetry") return false unless details - index_response = Excon.get( - "https://pypi.org/pypi/#{normalised_name(details['name'])}/json/", - idempotent: true, - **SharedHelpers.excon_defaults + index_response = Dependabot::RegistryClient.get( + url: "https://pypi.org/pypi/#{normalised_name(details['name'])}/json/" ) return false unless index_response.status == 200 diff --git a/python/lib/dependabot/python/update_checker/latest_version_finder.rb b/python/lib/dependabot/python/update_checker/latest_version_finder.rb index c60c1c4f796..f59f8d46183 100644 --- a/python/lib/dependabot/python/update_checker/latest_version_finder.rb +++ b/python/lib/dependabot/python/update_checker/latest_version_finder.rb @@ -7,7 +7,7 @@ require "dependabot/dependency" require "dependabot/python/update_checker" require "dependabot/update_checkers/version_filters" -require "dependabot/shared_helpers" +require "dependabot/registry_client" require "dependabot/python/authed_url_builder" require "dependabot/python/name_normaliser" @@ -214,18 +214,16 @@ def index_urls end def registry_response_for_dependency(index_url) - Excon.get( - index_url + normalised_name + "/", - idempotent: true, - **SharedHelpers.excon_defaults(headers: { "Accept" => "text/html" }) + Dependabot::RegistryClient.get( + url: index_url + normalised_name + "/", + headers: { "Accept" => "text/html" } ) end def registry_index_response(index_url) - Excon.get( - index_url, - idempotent: true, - **SharedHelpers.excon_defaults(headers: { "Accept" => "text/html" }) + Dependabot::RegistryClient.get( + url: index_url, + headers: { "Accept" => "text/html" } ) end