1

Finally I enabled SSL in Apache on my Mac Os. Now I would like to make HTTPS GET/POST requests from a my RoR3 application to another RoR3 application and receive the response.

How can I make this in Ruby on Rails?

For the HTTP GEST/POST "version" I have already solved the issue using Ruby's Net::HTTP class:

require 'net/http'

url = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
  http.request(req)
}
puts res.body
Community
  • 1
  • 1
user502052
  • 14,803
  • 30
  • 109
  • 188
  • 1
    Are you trying to fetch the page and then extract data from it? Is the page rendering a model? If so, I'd recommend using a JSON transport instead of HTML, or even better, ActiveResource (http://api.rubyonrails.org/classes/ActiveResource/Base.html). IMHO, using Net::HTTP isn' the greatest idea, theres usually a better way to format the data based on what you are trying to do. – hornairs Jan 06 '11 at 17:00
  • try https://github.com/dbalatero/typhoeus – codevoice Jan 06 '11 at 18:39

0 Answers0