Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Net::HTTPHeader#get_fields
(::interned key) -> (nil | ::Array[::String])
get_fields(key)
lib/net/http/header.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/net/http/header.rb, line 306
def get_fields(key)
stringified_downcased_key = key.downcase.to_s
return nil unless @header[stringified_downcased_key]
@header[stringified_downcased_key].dup
end
Returns the array field value for the given key, or nil if there is no such field; see Fields:
Example
res = Net::HTTP.get_response(hostname, '/todos/1') res.get_fields('Connection') # => ["keep-alive"] res.get_fields('Nosuch') # => nil