Class: RecipeScrapers::Http::FollowRedirects

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/recipe_scrapers/http/follow_redirects.rb

Overview

Follows 301, 302, 303, 307 and 308 redirects as GET requests. Every hop goes through the middleware after it again, so AddressGuard checks each host. The Authorization header is dropped when a redirect leaves the origin. Registered as :recipe_scrapers_follow_redirects.

Instance Method Summary collapse

Constructor Details

#initialize(app, limit: 3) ⇒ FollowRedirects



20
21
22
23
# File 'lib/recipe_scrapers/http/follow_redirects.rb', line 20

def initialize(app, limit: 3)
  super(app)
  @limit = limit
end

Instance Method Details

#call(env) ⇒ Faraday::Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the response of the last hop.

Raises:



30
31
32
# File 'lib/recipe_scrapers/http/follow_redirects.rb', line 30

def call(env)
  follow(env, @limit)
end