Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. 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.3 · 3.1 · 3.0