Top Level Namespace
Defined Under Namespace
Modules: RedirectFollowGet
Instance Method Summary collapse
Instance Method Details
#redirect_follow_get(url, limit: 10) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/redirect_follow_get.rb', line 19 def redirect_follow_get(url, limit: 10) raise RedirectFollowGet::TooManyRedirects, 'too many HTTP redirects' if limit.zero? uri = RedirectFollowGet.parse_url(url) case response = Net::HTTP.get_response(uri) when Net::HTTPSuccess response when Net::HTTPRedirection location = response['location'] redirect_follow_get(location, limit: limit - 1) else response end end |