is-mime-content-type
Matches the "Content-Type" header of the stream to custom-defined accept rules. Returns true if the "Content-Type" header exists and the rules match its value, otherwise returns false. A stream without "Content-Type" header will be treated as "application/octet-stream".
The accept rules have the following format, in extended Backus-Naur form (EBNF) notation:
Match ::= Single ("," Single)* Single ::= Spaces? Type-Match ( Spaces? ";" Spaces? Parameter )* Spaces? Type-Match ::= "*/*" | Type "/*" | Type "/*+" Suffix | Type "/" Subtype
Parameter ::= Name "=" Value |
Signature
is-mime-content-type(s:stream, accept:string) -> Boolean |
Parameters
Name | Type | Description |
---|---|---|
s | stream | Specifies the input stream. |
accept | string | Specifies the custom-defined accept rules. |
Examples
The following expression will return true if stream msg contains the header Content-Type: text/html; charset=utf-8 or Content-Type: text/plain; charset=utf-8.
is-mime-content-type(msg, "text/*; charset=\"utf-8\"") |
The following expression will return true if stream msg contains the header Content-Type: application/rss+xml or Content-Type: application/svg+xml.
is-mime-content-type(msg, "application/*+xml") |
You can also match multiple rules by separating them with a comma. For example, the following expression will return true if stream msg contains the header Content-Type: text/xml or Content-Type: application/xml:
is-mime-content-type(msg, "text/xml, application/xml") |