When connecting to a website using Net::HTTP
you can parse the URL and output each of the URL headers by using #.each_header
. I understand what the encoding and the user agent and such means, but not what the "accept"=>["*/*"]
part is. Is this the accepted payload? Or is it something else?
require 'net/http'
uri = URI('http://www.bible-history.com/subcat.php?id=2')
http://www.bible-history.com/subcat.php?id=2>
http_request = Net::HTTP::Get.new(uri)
http_request.each_header { |header| puts header }
# => {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], "accept"=>["*/*"], "user-agent"=>["Ruby"], "host"=>["www.bible-history.com"]}
From https://www.w3.org/Protocols/HTTP/HTRQ_Headers.html#z3
Basically, it specifies what kinds of content you can read back. If you write an api client, you may only be interested in
application/json
, for example (and you couldn't care less abouttext/html
).In this case, your header would look like this:
And the app will know not to send any html your way.