const class std::MimeType

sys::Obj
  std::MimeType

@Serializable { simple=true }

MimeType represents the parsed value of a Content-Type header per RFC 2045 section 5.1.

charset

Charset charset()

If a charset parameter is specified, then map it to the Charset instance, otherwise return Charset.utf8.

dir

const static MimeType dir := ...

equals

virtual override Bool equals(Obj? that)

Equality is based on the case insensitive mediaType and subType, and params (keys are case insensitive and values are case sensitive).

forExt

static MimeType? forExt(Str s)

Map a case insensitive file extension to a MimeType. This mapping is configured via "etc/sys/ext2mime.props". If no mapping is available return null.

fromStr

static new fromStr(Str s)

Parse from string format. If invalid format and checked is false return null, otherwise throw ParseErr. Parenthesis comments are treated as part of the value.

hash

virtual override Int hash()

Hash code is derived from the mediaType, subType, and params hashes.

imageGif

const static MimeType imageGif := ...

imageJpeg

const static MimeType imageJpeg := ...

imagePng

const static MimeType imagePng := ...

mediaType

const Str mediaType

The primary media type always in lowercase:

text/html  =>  text
noParams

MimeType noParams()

Return an instance with this mediaType and subType, but strip any parameters.

params

const Map<Str,Str> params

Additional parameters stored in case-insensitive map. If no parameters, then this is an empty map.

text/html; charset=utf-8    =>  [charset:utf-8]
text/html; charset="utf-8"  =>  [charset:utf-8]
parseParams

static Map<Str,Str>? parseParams(Str s, Bool checked := true)

Parse a set of attribute-value parameters where the values may be tokens or quoted-strings. The resulting map is case insensitive. If invalid format and checked is false return null, otherwise throw ParseErr. Parenthesis comments are not supported.

Examples:

a=b; c="d"  =>  ["a":"b", "c"="d"]
subType

const Str subType

The subtype always in lowercase:

text/html  =>  html
textCss

const static MimeType textCss := ...

textHtml

const static MimeType textHtml := ...

textHtmlUtf8

const static MimeType textHtmlUtf8 := ...

textJs

const static MimeType textJs := ...

textJsUtf8

const static MimeType textJsUtf8 := ...

textJson

const static MimeType textJson := ...

textJsonUtf8

const static MimeType textJsonUtf8 := ...

textPlain

const static MimeType textPlain := ...

textPlainUtf8

const static MimeType textPlainUtf8 := ...

textXml

const static MimeType textXml := ...

textXmlUtf8

const static MimeType textXmlUtf8 := ...

toStr

virtual override Str toStr()

Encode as a MIME message according to RFC 822. This is always the exact same string passed to fromStr.