How to specify "http request header" in OpenURI How to specify "http request header" in OpenURI ruby ruby

How to specify "http request header" in OpenURI


According to the documentation, you can pass a hash of http headers as the second argument to open:

open("http://www.ruby-lang.org/en/",   "User-Agent" => "Ruby/#{RUBY_VERSION}",   "From" => "foo@bar.invalid",   "Referer" => "http://www.ruby-lang.org/") {|f|   # ... }