turn a URL into the various pieces needed by net/http.
require 'net/http'
url = URI.parse('http://www.rubyinside.com/test.txt')
Net::HTTP.start(url.host, url.port) do |http|
req = Net::HTTP::Get.new(url.path)
puts http.request(req).body
end
Related examples in the same category