class Rack::MediaType

def type(content_type)

http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7
For more information on the use of media types in HTTP, see:

"text/plain;charset=utf-8", the media-type is "text/plain".
without any media type parameters. e.g., when CONTENT_TYPE is
The media type (type/subtype) portion of the CONTENT_TYPE header
def type(content_type)
  return nil unless content_type
  if type = content_type.split(SPLIT_PATTERN, 2).first
    type.rstrip!
    type.downcase!
    type
  end
end