class Sinatra::Request::MimeTypeEntry
def accepts?(entry)
def accepts?(entry) File.fnmatch(entry, self) && matches_params?(entry.params) end
def initialize(entry)
def initialize(entry) params = entry.scan(HEADER_PARAM).map! do |s| key, value = s.strip.split('=', 2) value = value[1..-2].gsub(/\\(.)/, '\1') if value.start_with?('"') [key, value] end @type = entry[/[^;]+/].delete(' ') @params = params.to_h end
def matches_params?(params)
def matches_params?(params) return true if @params.empty? params.all? { |k, v| !@params.key?(k) || @params[k] == v } end
def to_str
def to_str @type end