A certain action must load an html page according a uri
parameter. It works fine for all valid uris, except those of the current server. Is there an easy way to request a page from within a controller?
require 'uri'
class MainController < ApplicationController
def foo
uri = URI(params[:uri])
if uri.host =~ /localhost|mydomain\.com/
# what goes here?
else
@html = Net::HTTP.get(uri)
end
# Do something useful with @html...
end
end
# The code should work for http://localhost/foo?uri=http://apple.com/
# as well as for http://localhost/foo?uri=http://localhost/bar