diff --git a/Gemfile.lock b/Gemfile.lock index ba45006..2458e8d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,8 +2,8 @@ PATH remote: . specs: diaspora_federation (0.3.0) - faraday (~> 1.0) - faraday_middleware (~> 1.0) + faraday (>= 1.0, < 3) + faraday-follow_redirects (~> 0.3) nokogiri (~> 1.6, >= 1.6.8) typhoeus (~> 1.0) valid (~> 1.0) @@ -53,27 +53,12 @@ GEM ethon (0.15.0) ffi (>= 1.15.0) fabrication (2.27.0) - faraday (1.8.0) - faraday-em_http (~> 1.0) - faraday-em_synchrony (~> 1.0) - faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0.1) - faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.1) - faraday-patron (~> 1.0) - faraday-rack (~> 1.0) - multipart-post (>= 1.2, < 3) + faraday (2.3.0) + faraday-net_http (~> 2.0) ruby2_keywords (>= 0.0.4) - faraday-em_http (1.0.0) - faraday-em_synchrony (1.0.0) - faraday-excon (1.1.0) - faraday-httpclient (1.0.1) - faraday-net_http (1.0.1) - faraday-net_http_persistent (1.2.0) - faraday-patron (1.0.0) - faraday-rack (1.0.0) - faraday_middleware (1.2.0) - faraday (~> 1.0) + faraday-follow_redirects (0.3.0) + faraday (>= 1, < 3) + faraday-net_http (2.0.3) ffi (1.15.4) fuubar (2.5.1) rspec-core (~> 3.0) @@ -107,15 +92,14 @@ GEM mini_portile2 (2.8.0) minitest (5.16.2) multi_xml (0.6.0) - multipart-post (2.1.1) nokogiri (1.13.7) mini_portile2 (~> 2.8.0) racc (~> 1.4) nyan-cat-formatter (0.12.0) rspec (>= 2.99, >= 2.14.2, < 4) - octokit (4.21.0) - faraday (>= 0.9) - sawyer (~> 0.8.0, >= 0.5.3) + octokit (4.25.1) + faraday (>= 1, < 3) + sawyer (~> 0.9) parallel (1.21.0) parser (3.0.3.0) ast (~> 2.4.1) @@ -136,7 +120,7 @@ GEM pry-byebug (3.8.0) byebug (~> 11.0) pry (~> 0.10) - public_suffix (4.0.6) + public_suffix (4.0.7) racc (1.6.0) rack (2.2.4) rack-test (2.0.2) @@ -204,9 +188,9 @@ GEM ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) rugged (1.0.1) - sawyer (0.8.2) + sawyer (0.9.2) addressable (>= 2.3.5) - faraday (> 0.8, < 2.0) + faraday (>= 0.17.3, < 3) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) diff --git a/diaspora_federation.gemspec b/diaspora_federation.gemspec index 241c7f1..ea41cb5 100644 --- a/diaspora_federation.gemspec +++ b/diaspora_federation.gemspec @@ -29,8 +29,8 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 2.7" - s.add_dependency "faraday", "~> 1.0" - s.add_dependency "faraday_middleware", "~> 1.0" + s.add_dependency "faraday", ">= 1.0", "< 3" + s.add_dependency "faraday-follow_redirects", "~> 0.3" s.add_dependency "nokogiri", "~> 1.6", ">= 1.6.8" s.add_dependency "typhoeus", "~> 1.0" s.add_dependency "valid", "~> 1.0" diff --git a/lib/diaspora_federation/http_client.rb b/lib/diaspora_federation/http_client.rb index 22dccae..756d06c 100644 --- a/lib/diaspora_federation/http_client.rb +++ b/lib/diaspora_federation/http_client.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "faraday" -require "faraday_middleware" +require "faraday/follow_redirects" module DiasporaFederation # A wrapper for {https://github.com/lostisland/faraday Faraday} @@ -32,7 +32,8 @@ module DiasporaFederation } @connection = Faraday::Connection.new(options) do |builder| - builder.response :follow_redirects, limit: DiasporaFederation.http_redirect_limit + builder.use Faraday::FollowRedirects::Middleware, limit: DiasporaFederation.http_redirect_limit + builder.adapter Faraday.default_adapter end diff --git a/spec/lib/diaspora_federation/http_client_spec.rb b/spec/lib/diaspora_federation/http_client_spec.rb index 5a4c5a7..ea3baa7 100644 --- a/spec/lib/diaspora_federation/http_client_spec.rb +++ b/spec/lib/diaspora_federation/http_client_spec.rb @@ -33,7 +33,8 @@ module DiasporaFederation stub_request(:get, "http://www.example.com") .to_return(status: 302, headers: {"Location" => "http://www.example.com"}) - expect { HttpClient.get("http://www.example.com") }.to raise_error FaradayMiddleware::RedirectLimitReached + expect { HttpClient.get("http://www.example.com") } + .to raise_error Faraday::FollowRedirects::RedirectLimitReached end it "uses the gem name as User-Agent" do diff --git a/test/dummy/config/initializers/faraday.rb b/test/dummy/config/initializers/faraday.rb deleted file mode 100644 index 856578c..0000000 --- a/test/dummy/config/initializers/faraday.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Use net_http in test, that's better supported by webmock -unless Rails.env.test? - require "typhoeus/adapters/faraday" - Faraday.default_adapter = :typhoeus -end