# File lib/jekyll/migrators/posterous.rb, line 12 def self.fetch(uri_str, limit = 10) # You should choose better exception. raise ArgumentError, 'Stuck in a redirect loop. Please double check your email and password' if limit == 0 response = nil Net::HTTP.start('posterous.com') do |http| req = Net::HTTP::Get.new(uri_str) req.basic_auth @email, @pass response = http.request(req) end case response when Net::HTTPSuccess then response when Net::HTTPRedirection then fetch(response['location'], limit - 1) else response.error! end end