The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<HTML>
<HEAD>
  <TITLE>MIME::Field::ContType</TITLE>
</HEAD>
<BODY 
       bgcolor="#FFFFFF" link="#CC3366" vlink="#993366" alink="#FF6666">
<FONT FACE="sans-serif" SIZE=-1><A HREF="http://www.zeegee.com" TARGET="_top"><IMG SRC="icons/zeegee.gif" ALT="ZeeGee Software" ALIGN="RIGHT" BORDER="0"></A><A NAME="__TOP__"><H1>MIME::Field::ContType</H1>
</A>
<P><B>This module is <FONT COLOR="#990000">BETA</FONT> code, which means that the interfaces are fairly stable BUT it has not been out in the community long enough to guarantee much testing. Use with caution! Please report any errors back to <A HREF="mailto:eryq@zeegee.com">eryq@zeegee.com</A> as soon as you can.</B><UL>
<LI> <A HREF="#NAME">NAME</A>
<LI> <A HREF="#DESCRIPTION">DESCRIPTION</A>
<LI> <A HREF="#SYNOPSIS">SYNOPSIS</A>
<LI> <A HREF="#PUBLIC_INTERFACE">PUBLIC INTERFACE</A>
<LI> <A HREF="#NOTES">NOTES</A>
<LI> <A HREF="#AUTHOR">AUTHOR</A>
</UL>
</A>

<P><HR>
<A NAME="NAME"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> NAME</H2></A>


<P>MIME::Field::ContType - a &quot;Content-type&quot; field



<P><HR>
<A NAME="DESCRIPTION"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> DESCRIPTION</H2></A>


<P>A subclass of Mail::Field.


<P><I>Don't use this class directly... its name may change in the future!</I>
Instead, ask Mail::Field for new instances based on the field name!



<P><HR>
<A NAME="SYNOPSIS"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> SYNOPSIS</H2></A>

<FONT SIZE=3 FACE="courier"><PRE>
    use Mail::Field;
    use MIME::Head;
    
    # Create an instance from some text:
    $field = Mail::Field-&gt;new('Content-type', 
                              'text/HTML; charset=&quot;US-ASCII&quot;');
    
    # Get the MIME type, like 'text/plain' or 'x-foobar'.
    # Returns 'text/plain' as default, as per RFC-1521:
    my ($type, $subtype) = split('/', $field-&gt;type);
</PRE></FONT>
<FONT SIZE=3 FACE="courier"><PRE>
    # Get generic information:
    print $field-&gt;name;
    
    # Get information related to &quot;message&quot; type:
    if ($type eq 'message') {
	print $field-&gt;id;
	print $field-&gt;number;
	print $field-&gt;total;
    }
    
    # Get information related to &quot;multipart&quot; type:
    if ($type eq 'multipart') {
	print $field-&gt;boundary;            # the basic value, fixed up
	print $field-&gt;multipart_boundary;  # empty if not a multipart message!
    }
    
    # Get information related to &quot;text&quot; type:
    if ($type eq 'text') {
	print $field-&gt;charset;      # returns 'us-ascii' as default
    }     
</PRE></FONT>


<P><HR>
<A NAME="PUBLIC_INTERFACE"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> PUBLIC INTERFACE</H2></A>



<DL>
<P><DT><B><A NAME="item:boundary">boundary</A></B></DT>
<DD>
Return the boundary field.  The boundary is returned exactly 
as given in the <CODE>Content-type:</CODE> field; that is, the leading 
double-hyphen (<CODE>--</CODE>) is <I>not</I> prepended.


<P>(Well, <I>almost</I> exactly... from RFC-1521:

<FONT SIZE=3 FACE="courier"><PRE>
   (If a boundary appears to end with white space, the white space 
   must be presumed to have been added by a gateway, and must be deleted.)  
</PRE></FONT>

<P>so we oblige and remove any trailing spaces.)


<P>Returns the empty string if there is no boundary, or if the boundary is
illegal (e.g., if it is empty after all trailing whitespace has been
removed).

<P><DT><B><A NAME="item:multipart_boundary">multipart_boundary</A></B></DT>
<DD>
Like <CODE>boundary()</CODE>, except that this will also return the empty
string if the message is not a multipart message.  In other words,
there's an automatic sanity check.

<P><DT><B><A NAME="item:type">type</A></B></DT>
<DD>
Try real hard to determine the content type (e.g., <CODE>&quot;text/plain&quot;</CODE>,
<CODE>&quot;image/gif&quot;</CODE>, <CODE>&quot;x-weird-type&quot;</CODE>, which is returned 
in all-lowercase.  


<P>A happy thing: the following code will work just as you would want,
even if there's no subtype (as in <CODE>&quot;x-weird-type&quot;</CODE>)... in such a case,
the $subtype would simply be the empty string:

<FONT SIZE=3 FACE="courier"><PRE>
    ($type, $subtype) = split('/', $head-&gt;mime_type);
</PRE></FONT>

<P>If the content-type information is missing, it defaults to <CODE>&quot;text/plain&quot;</CODE>, 
as per RFC-1521:

<FONT SIZE=3 FACE="courier"><PRE>
    Default RFC-822 messages are typed by this protocol as plain text in
    the US-ASCII character set, which can be explicitly specified as
    &quot;Content-type: text/plain; charset=us-ascii&quot;.  If no Content-Type is
    specified, this default is assumed.  
</PRE></FONT>

<P><B>Note:</B> under the &quot;be liberal in what we accept&quot; principle, this routine
no longer syntax-checks the content type.  If it ain't empty,
just downcase and return it.

</DL>



<P><HR>
<A NAME="NOTES"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> NOTES</H2></A>


<P>Since nearly all (if not all) parameters must have non-empty values
to be considered valid, we just return the empty string to signify 
missing fields.  If you need to get the <I>real</I> underlying value,
use the inherited <CODE>param()</CODE> method (which returns undef if the 
parameter is missing).



<P><HR>
<A NAME="AUTHOR"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> AUTHOR</H2></A>


<P>Eryq (<I><FILE><A HREF="mailto:eryq@zeegee.com">eryq@zeegee.com</A></FILE></I>), ZeeGee Software Inc (<I><FILE><A HREF="http://www.zeegee.com">http://www.zeegee.com</A></FILE></I>).

<P><HR>
<ADDRESS><FONT SIZE=-1>
Generated Wed Jan 17 01:58:16 2001 by cvu_pod2html
</FONT></ADDRESS>
</FONT></BODY>
</HTML>