web_proxy replaces the reference to Net::HTTP when using the start method. : Proxy « Network « Ruby






web_proxy replaces the reference to Net::HTTP when using the start method.



require 'net/http'

web_proxy = Net::HTTP::Proxy('your.proxy.hostname.or.ip', 8080)

url = URI.parse('http://www.rubyinside.com/test.txt')

web_proxy.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.Get response for HTTP requests,