Class: Coelacanth::Redirect
- Inherits:
-
Object
- Object
- Coelacanth::Redirect
- Defined in:
- lib/coelacanth/redirect.rb
Overview
Coelacanth::Redirect
Instance Method Summary collapse
Instance Method Details
#resolve_redirect(url, limit = 10) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/coelacanth/redirect.rb', line 10 def resolve_redirect(url, limit = 10) @url = url if url && Validator.new.valid_url?(url) raise Coelacanth::DeepRedirectError, "Too many redirect" if limit.zero? raise Coelacanth::RedirectError, "Url or location is nil" if @url.nil? response = Coelacanth::HTTP.get_response(URI.parse(@url)) @status_code = response.code @origin_response = response handle_response(@origin_response, limit) rescue Coelacanth::TimeoutError @status_code = nil @origin_response = nil @url end |