NAME

cs::MIME - handle Multipurpose Internet Mail Extension data


SYNOPSIS

use cs::MIME;


DESCRIPTION

This module implements methods for dealing with MIME data. It is a subclass of the cs::RFC822(3) module.


GENERAL FUNCTIONS

parseContentType(content-type)

Parse a Content-Type line content-type, returning a tuple of (type,subtype,params,unparsed) being the type and subtype, a hashref containing any parameters on the line and any remaining data which could not be parsed.

parseTypeParams(parameter-string)

Parse a the parameters section of a Content-Type line returning a tuple of (params,unparsed) a hashref containing any parameters on the line and any remaining data which could not be parsed.

decodedSource(source, enc, istext)

Return a new cs::Source containing the decoded content of the supplied cs::Source source according to the supplied encoding string enc (as for the Content-Encoding or Content-Transfer-Encoding headers) and optional istext flag. istext defaults to false for BASE64 data and true for QUOTED-PRINTABLE data.


OBJECT CREATION

new cs::MIME source, usecsize

Create a MIME object. If source (a file pathname or a cs::Source) is supplied then its content is copied and the headers extracted, leaving the source positioned just past the end of the body. To avoid this cost, call with no cs::Source and use the UseHdrs method to place header infomation into the object. The optional usecsize parameter says to trust the Content-Size header if present, placing a limit on the data read from the source. The default is to ignore it.


OBJECT METHODS

Type()

Return the type component of the object's Content-Type.

SubType()

Return the subtype component of the object's Content-Type.

UseHdrs(hdrs)

Incorporate the headers from the cs::RFC822 object hdrs.

UseSource(source,usecsize,sinkfile,keepsink)

Read headers and body from the supplied source. The optional usecsize parameter says to trust the Content-Size header if present, placing a limit on the data read from the source. The default is to ignore it. Supplying the optional sinkfile parameter causes UseSource() to store the source in the named file sinkfile instead of memory. The optional parameter keepsink specifies whether the sinkfile is to be unlinked on object destruction.

Body(decoded,istext)

Return a string containing the body of this object, decoded if decoded is true (the default is false). The optional parameter istext is used as in the decodedSource() function.

BodySource(decoded,istext)

Return a new cs::Source containing the body of this object, decoded if decoded is true (the default is false). The optional parameter istext is used as in the decodedSource() function.

ContentType(noparams)

Return the body for the Content-Type header. If the optional noparams is true, suppress the ``;param=value'' suffices.

Parts(wantPrePost)

Collect pretext, parts and posttext from the object (presumably multipart) and return an array of cs::MIME objects for each part. If the optional parameter wantPrePost is true, prefix the pretext and posttext to the array.


SEE ALSO

cs::RFC822(3), cs::Source(3)

RFCs: 822 - Internet Mail Messages, 1344 - Implications of MIME for Internet Mail Gateways, 1437 - The Extension of MIME Content-Types to a New Medium, 1521 - Media Type Registration Procedure


AUTHOR

Cameron Simpson <cs@zip.com.au>