Module: Bidi2pdfRails::TestHelpers::RequestHelper
- Defined in:
- lib/bidi2pdf_rails/test_helpers/request_helper.rb
Instance Method Summary collapse
Instance Method Details
#follow_redirects(response, max_redirects = 10) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/bidi2pdf_rails/test_helpers/request_helper.rb', line 15 def follow_redirects(response, max_redirects = 10) redirect_count = 0 while response.is_a?(Net::HTTPRedirection) && redirect_count < max_redirects redirect_url = response["location"] response = get_pdf_response redirect_url redirect_count += 1 end response end |
#get_pdf_response(path) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/bidi2pdf_rails/test_helpers/request_helper.rb', line 5 def get_pdf_response(path) uri = if path =~ %r{\Ahttps?://} URI(path) else URI.join(server_url, path) end Net::HTTP.get_response(uri) end |