Method: Gem::Net::HTTPHeader#content_type
- Defined in:
- lib/rubygems/net-http/lib/net/http/header.rb
#content_type ⇒ Object
Returns 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.content_type # => "application/json"
701 702 703 704 705 706 707 708 709 710 711 |
# File 'lib/rubygems/net-http/lib/net/http/header.rb', line 701 def content_type main = main_type() return nil unless main sub = sub_type() if sub "#{main}/#{sub}" else main end end |