Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Net::HTTPHeader#to_hash
to_hash
lib/net/http/header.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/net/http/header.rb, line 477
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"]}