Sha256: ce619bc66ec9094f6dbd366a48f6e3cc769f858d8a47bd4a70ad0d77f6e44885
Contents?: true
Size: 597 Bytes
Versions: 44
Compression:
Stored size: 597 Bytes
Contents
module HTTP ContentType = Struct.new(:mime_type, :charset) do MIME_TYPE_RE = %r{^([^/]+/[^;]+)(?:$|;)} CHARSET_RE = /;\s*charset=([^;]+)/i class << self # Parse string and return ContentType struct def parse(str) new mime_type(str), charset(str) end private # :nodoc: def mime_type(str) md = str.to_s.match MIME_TYPE_RE md && md[1].to_s.strip.downcase end # :nodoc: def charset(str) md = str.to_s.match CHARSET_RE md && md[1].to_s.strip.gsub(/^"|"$/, "") end end end end
Version data entries
44 entries across 44 versions & 1 rubygems