instance method
Net::HTTPHeader#sub_type
() -> (nil | ::String)
sub_type
lib/net/http/header.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/net/http/header.rb, line 742
def sub_type
return nil unless @header['content-type']
_, sub = *self['Content-Type'].split(';').first.to_s.split('/')
return nil unless sub
sub.strip
end
Returns the trailing (‘subtype’) part of the media type from 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.sub_type # => "json"