Method: Gem::Net::HTTPHeader#main_type
- Defined in:
- lib/rubygems/net-http/lib/net/http/header.rb
#main_type ⇒ Object
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:
res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
res['content-type'] # => "application/json; charset=utf-8"
res.main_type # => "application"
723 724 725 726 |
# File 'lib/rubygems/net-http/lib/net/http/header.rb', line 723 def main_type return nil unless @header['content-type'] self['Content-Type'].split(';').first.to_s.split('/')[0].to_s.strip end |