Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Net::HTTPHeader#to_hash

to_hash

Returns a hash of the key/value pairs:

Example
req = Net::HTTP::Get.new(uri)
req.to_hash
# =>
{"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
 "accept"=>["*/*"],
 "user-agent"=>["Ruby"],
 "host"=>["jsonplaceholder.typicode.com"]}
See also #sub_type #type_params #set_range also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0