.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "MIME::Field::ContType 3pm" .TH MIME::Field::ContType 3pm 2024-04-27 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME MIME::Field::ContType \- a "Content\-type" field .SH DESCRIPTION .IX Header "DESCRIPTION" A subclass of Mail::Field. .PP \&\fIDon't use this class directly... its name may change in the future!\fR Instead, ask Mail::Field for new instances based on the field name! .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& use Mail::Field; \& use MIME::Head; \& \& # Create an instance from some text: \& $field = Mail::Field\->new(\*(AqContent\-type\*(Aq, \& \*(Aqtext/HTML; charset="US\-ASCII"\*(Aq); \& \& # Get the MIME type, like \*(Aqtext/plain\*(Aq or \*(Aqx\-foobar\*(Aq. \& # Returns \*(Aqtext/plain\*(Aq as default, as per RFC 2045: \& my ($type, $subtype) = split(\*(Aq/\*(Aq, $field\->type); \& \& # Get generic information: \& print $field\->name; \& \& # Get information related to "message" type: \& if ($type eq \*(Aqmessage\*(Aq) { \& print $field\->id; \& print $field\->number; \& print $field\->total; \& } \& \& # Get information related to "multipart" type: \& if ($type eq \*(Aqmultipart\*(Aq) { \& print $field\->boundary; # the basic value, fixed up \& print $field\->multipart_boundary; # empty if not a multipart message! \& } \& \& # Get information related to "text" type: \& if ($type eq \*(Aqtext\*(Aq) { \& print $field\->charset; # returns \*(Aqus\-ascii\*(Aq as default \& } .Ve .SH "PUBLIC INTERFACE" .IX Header "PUBLIC INTERFACE" .IP boundary 4 .IX Item "boundary" Return the boundary field. The boundary is returned exactly as given in the \f(CW\*(C`Content\-type:\*(C'\fR field; that is, the leading double-hyphen (\f(CW\*(C`\-\-\*(C'\fR) is \fInot\fR prepended. .Sp (Well, \fIalmost\fR exactly... from RFC 2046: .Sp .Vb 2 \& (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.) .Ve .Sp so we oblige and remove any trailing spaces.) .Sp 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). .IP multipart_boundary 4 .IX Item "multipart_boundary" Like \f(CWboundary()\fR, 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. .IP type 4 .IX Item "type" Try real hard to determine the content type (e.g., \f(CW"text/plain"\fR, \&\f(CW"image/gif"\fR, \f(CW"x\-weird\-type"\fR, which is returned in all-lowercase. .Sp A happy thing: the following code will work just as you would want, even if there's no subtype (as in \f(CW"x\-weird\-type"\fR)... in such a case, the \f(CW$subtype\fR would simply be the empty string: .Sp .Vb 1 \& ($type, $subtype) = split(\*(Aq/\*(Aq, $head\->mime_type); .Ve .Sp If the content-type information is missing, it defaults to \f(CW"text/plain"\fR, as per RFC 2045: .Sp .Vb 4 \& Default RFC 2822 messages are typed by this protocol as plain text in \& the US\-ASCII character set, which can be explicitly specified as \& "Content\-type: text/plain; charset=us\-ascii". If no Content\-Type is \& specified, this default is assumed. .Ve .Sp \&\fBNote:\fR under the "be liberal in what we accept" principle, this routine no longer syntax-checks the content type. If it ain't empty, just downcase and return it. .SH NOTES .IX Header "NOTES" 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 \fIreal\fR underlying value, use the inherited \f(CWparam()\fR method (which returns undef if the parameter is missing). .SH "SEE ALSO" .IX Header "SEE ALSO" MIME::Field::ParamVal, Mail::Field .SH AUTHOR .IX Header "AUTHOR" Eryq (\fIeryq@zeegee.com\fR), ZeeGee Software Inc (\fIhttp://www.zeegee.com\fR). Dianne Skoll (dianne@skoll.ca)