logo

const final class

sys::MimeType

sys::Obj
  sys::MimeType

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

Slots

equals

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).

Source

forExt

static MimeType forExt(Str ext)

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

Source

fromStr

static MimeType fromStr(Str s, Bool checked := true)

Parse from string format. If invalid format and checked is false return null, otherwise throw ParseErr. Parenthesis comments are not supported.

Source

hash

override Int hash()

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

Source

mediaType

Str mediaType()

The primary media type always in lowercase:

text/html  =>  text

Source

params

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]

Source

subType

Str subType()

The subtype always in lowercase:

text/html  =>  html

Source

toStr

override Str toStr()

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

Source