Class: HTTP::Redirector
- Inherits:
-
Object
- Object
- HTTP::Redirector
- Defined in:
- lib/http/redirector.rb
Defined Under Namespace
Classes: EndlessRedirectError, TooManyRedirectsError
Constant Summary collapse
- REDIRECT_CODES =
HTTP status codes which indicate redirects
[300, 301, 302, 303, 307, 308].freeze
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ Redirector
constructor
:nodoc:.
-
#perform(request, response, &block) ⇒ Object
Follows redirects until non-redirect response found.
Constructor Details
#initialize(options = nil) ⇒ Redirector
:nodoc:
13 14 15 16 17 |
# File 'lib/http/redirector.rb', line 13 def initialize( = nil) = {:max_hops => 5} unless .respond_to?(:fetch) @max_hops = .fetch(:max_hops, 5) @max_hops = false if @max_hops && 1 > @max_hops.to_i end |
Instance Method Details
#perform(request, response, &block) ⇒ Object
Follows redirects until non-redirect response found
20 21 22 23 |
# File 'lib/http/redirector.rb', line 20 def perform(request, response, &block) reset(request, response) follow(&block) end |