Skip to content

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

instance method

Net::HTTPHeader#get_fields

get_fields(key)

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
See also #form_data= #key? #fetch #main_type also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0