HTTPMediaType

Represents an encoded data-format, used in HTTP, HTML, email, and elsewhere.

HTTPMediaType.swift:52
struct HTTPMediaType
text/plain
application/json; charset=utf8

Description from rfc2045:

In general, the top-level media type is used to declare the general
type of data, while the subtype specifies a specific format for that
type of data.  Thus, a media type of "image/xyz" is enough to tell a
user agent that the data is an image, even if the user agent has no
knowledge of the specific image format "xyz".  Such information can
be used, for example, to decide whether or not to show a user the raw
data from an unrecognized subtype -- such an action might be
reasonable for unrecognized subtypes of text, but not for
unrecognized subtypes of image or audio.  For this reason, registered
subtypes of text, image, audio, and video should not contain embedded
information that is really of a different type.  Such compound
formats should be represented using the "multipart" or "application"
types.

Simplified format:

mediaType := type "/" subtype *(";" parameter)
; Matching of media type and subtype
; is ALWAYS case-insensitive.

type := token

subtype := token

parameter := attribute "=" value

attribute := token
; Matching of attributes
; is ALWAYS case-insensitive.

token := 1*<any (US-ASCII) CHAR except SPACE, CTLs,
    or tspecials>

value := token
; token MAY be quoted

tspecials :=  "(" / ")" / "<" / ">" / "@" /
              "," / ";" / ":" / "\" / <">
              "/" / "[" / "]" / "?" / "="
; Must be in quoted-string,
; to use within parameter values