Send Custom Headers Ruby Net::HTTP
This code snippet breaks down sending custom headers in Ruby.
The Web Dev Zone is brought to you in partnership with Mendix. Discover how IT departments looking for ways to keep up with demand for business apps has caused a new breed of developers to surface - the Rapid Application Developer.
require "net/http" require "uri" url = URI.parse("http://www.whatismyip.com/automation/n09230945.asp") req = Net::HTTP::Get.new(url.path) req.add_field("X-Forwarded-For", "0.0.0.0") res = Net::HTTP.new(url.host, url.port).start do |http| http.request(req) end puts res.body