Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Ruby

Idiom #101 Load from HTTP GET request into a string

Make an HTTP request with method GET to the URL u, then store the body of the response in the string s.

require 'net/http'
u = URI("http://example.com/index.html")
s = Net::HTTP.get_response(u).body
(def s (slurp u))

New implementation...