NAME
Courriel::ContentType - The content type for an email part
VERSION
version 0.05
SYNOPSIS
my $ct = $part->content_type();
print $ct->mime_type();
print $ct->charset();
my %attr = $ct->attributes();
while ( my ( $k, $v ) = each %attr ) {
print "$k => $v\n";
}
DESCRIPTION
This class represents the contents of a "Content-Type" header attached to an email part. Such headers always include a mime type, and may also include additional information such as a charset or other attributes.
Here are some typical headers:
Content-Type: text/plain; charset=utf-8
Content-Type: multipart/alternative; boundary=abcdefghijk
Content-Type: image/jpeg; name="Filename.jpg"
API
This class supports the following methods:
Courriel::ContentType->new( ... )
This method creates a new object. It accepts the following parameters:
mime_type
A string like "text/plain" or "multipart/alternative". This is required.
attributes
A hash reference of attributes from the header, such as a boundary, charset, etc. This is optional, and can be empty.
$ct->mime_type()
Returns the mime type value passed to the constructor.
$ct->charset()
Returns the charset for the content type.
This defaults to the value found in the attributes
or "us-ascii" as a fallback.
$ct->attributes()
Returns a hash (not a reference) of the attributes passed to the constructor.
$ct->get_attribute($key)
Given a key, returns the value of the named attribute. Obviously, this value can be undef
if the attribute doesn't exist.
$ct->as_header_value()
Returns the object as a string suitable for a header value (but not folded).
AUTHOR
Dave Rolsky <autarch@urth.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2011 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)