Simple and partial implementation of MIME encoding. MIME is covered
by RFC 2045. This library is used by e.g., http_post_data/3
when using the
form_data(+ListOfData) input specification.
MIME decoding is now arranged through
the clib package, based on the external librfc2045 library. Most likely
the functionality of this package will be moved to the same library
someday. Packing however is a lot simpler then parsing.
- [det]mime_pack(+Inputs, +Out:stream, ?Boundary)
- Pack a number of inputs into a MIME package using a specified or
generated boundary. The generated boundary consists of the current time
in milliseconds since the epoch and 10 random hexadecimal numbers. Inputs
is a list of documents that is added to the mime message. Each
element is one of:
- Name the document. This emits a header of the form below. The
filenameis present if Value is of the form
file(File). Value may be any of remaining value specifications.
Content-Disposition: form-data; name="Name"[; filename="<File>"
- Tokens is a list of HTML tokens as produced by html//1. The token list is emitted using print_html/1.
- Emit the contents of File. The
Content-typeis derived from the File using file_mime_type/2. If the content-type is
text/_, the file data is copied in text mode, which implies that it is read in the default encoding of the system and written using the encoding of the Out stream. Otherwise the file data is copied binary.
- stream(In, Len)
- Content is the next Len units from In. Data is copied using copy_stream_data/3. Units is bytes for binary streams and characters codes for text streams.
- Content of the stream In, copied using copy_stream_data/2. This is often used with memory files (see new_memory_file/1).
- mime(Attributes, Value,)
- Create a MIME header from Attributes and add Value,
which can be any of remaining values of this list. Attributes
character_set(CharSet). This can be used to give a content-type to values that otherwise do not have a content-type. For example:
mime([type(text/html)], '<b>Hello World</b>',