Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Net::HTTPHeader#type_params
() -> ::Hash[untyped, untyped]
type_params
lib/net/http/header.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/net/http/header.rb, line 753
def type_params
result = {}
list = self['Content-Type'].to_s.split(';')
list.shift
list.each do |param|
k, v = *param.split('=', 2)
result[k.strip] = v.strip
end
result
end
Returns the trailing (‘parameters’) part of the value of field 'Content-Type', or nil if no such field exists; see Content-Type response header:
Example
res = Net::HTTP.get_response(hostname, '/todos/1') res['content-type'] # => "application/json; charset=utf-8" res.type_params # => {"charset"=>"utf-8"}