Skip to content
instance method

Net::HTTPHeader#main_type

() -> (nil | ::String)
main_type

Returns the leading (‘type’) 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.main_type       # => "application"
See also #key? #proxy_basic_auth #get_fields #range also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0