turn a URL into the various pieces needed by net/http. : net http library « Network « Ruby






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

1.The net/http Library
2.Get body of response