How do I get the contents of an http request in Ruby?
http, ruby, ruby-on-rails
Solution
The standard library package `open-uri` is what you're after:
require 'open-uri'
contents = open('http://www.example.com') {|io| io.read}
# or
contents = URI.parse('http://www.example.com').read
Problem
In PHP I can do this: ``` $request = "http://www.example.com/someData"; $response = file_get_contents($request); ``` How would I do the same thing in Ruby (or some Rails method?) I've been googling for a half an hour and coming up completely short.