Namespace: joker.mime
v1.0Contents
Summary
Parses MIME media types, entities, message bodies, and attachments.
Index
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
(None.)
Variables
-
(None.)
Functions, Macros, and Special Forms
-
attachments
Function v1.9.0(attachments entity)(attachments ^Map entity)(attachments entity opts)(attachments ^Map entity ^Map opts)Returns attachment-like leaf entities from a MIME entity tree.
show types
A part is included when Content-Disposition is attachment. By default inline
parts with a filename are also included, which covers common inline images.
opts may contain:
- include-inline? - false to exclude inline/file-name parts; defaults to true -
body
Function v1.9.0(body entity)(body ^Map entity)(body entity opts)(body ^Map entity ^Map opts)Extracts human-readable body content from a MIME entity tree.
show types
Returns {:text text-or-nil :html html-or-nil}. Attachment-like parts are
ignored. The function handles both multipart and non-multipart entities;
text/plain leaves become :text and text/html leaves become :html. If multiple
matching leaves exist, the first value of each type is returned. -
decode-transfer-encoding
Function v1.9.0(decode-transfer-encoding encoding content)(decode-transfer-encoding ^Object encoding ^String content)Decodes content according to a MIME Content-Transfer-Encoding value.
show types
Supported encodings are nil/empty, 7bit, 8bit, binary, base64, and
quoted-printable. The returned string contains raw decoded bytes and may be
binary data. Throws Error for invalid encoded data or unsupported encodings. -
parse-media-type
Function v1.9.0(parse-media-type s)(parse-media-type ^String s)Parses a MIME media type or disposition value and returns
show types
{:type type :params {name value ...}}.
The input may be a Content-Type value such as
"text/plain; charset=utf-8" or a Content-Disposition value such as
"attachment; filename=report.pdf". Parameter names are lower-case as
returned by Go's mime.ParseMediaType. Throws Error when s is invalid. -
read-entity
Function v1.9.0(read-entity headers body)(read-entity ^Map headers ^String body)(read-entity headers body opts)(read-entity ^Map headers ^String body ^Map opts)Parses a MIME entity from headers and body and returns a recursive map.
show types
headers must be a map like {"Header-Name" ["value" ...]}; body is the
raw entity body. Non-multipart entities contain decoded :content and :size.
Multipart entities contain :parts. Content-Transfer-Encoding is decoded for
leaf entities.
Entity maps contain keys such as:
- :headers
- :content-type
- :content-type-params
- :disposition
- :disposition-params
- :filename
- :safe-filename
- :content-transfer-encoding
- :content
- :size
- :path
- :parts
Missing Content-Type defaults to text/plain. Binary content is represented as
a Joker string containing raw bytes.
opts may contain:
- include-content? - false to omit :content from leaf entities
- max-depth - maximum multipart nesting depth; defaults to 32
- max-part-bytes - maximum bytes to buffer for any MIME part; nil/unset means
unlimited