Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Net::HTTPHeader#to_hash
() -> ::Hash[::String, ::Array[::String]]
to_hash
lib/net/http/header.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/net/http/header.rb, line 495
def to_hash
@header.dup
end
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"]}