{"id":6754,"date":"2022-12-20T19:33:36","date_gmt":"2022-12-20T22:33:36","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/mimefieldconttype-man3\/"},"modified":"2022-12-20T19:33:36","modified_gmt":"2022-12-20T22:33:36","slug":"mimefieldconttype-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/mimefieldconttype-man3\/","title":{"rendered":"MIME::Field::ContType (man3)"},"content":{"rendered":"<h1 align=\"center\">MIME::Field::ContType<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#PUBLIC INTERFACE\">PUBLIC INTERFACE<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">MIME::Field::ContType \u2212 a &#8220;Content\u2212type&#8221; field<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">A subclass of Mail::Field.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>Don\u2019t use this class directly&#8230; its name may change in the future!<\/i> Instead, ask Mail::Field for new instances based on the field name!<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">use Mail::Field; <br \/> use MIME::Head; <br \/> # Create an instance from some text: <br \/> $field = Mail::Field\u2212>new(&#8216;Content\u2212type&#8217;, <br \/> &#8216;text\/HTML; charset=&#8221;US\u2212ASCII&#8221;&#8216;); <br \/> # Get the MIME type, like &#8216;text\/plain&#8217; or &#8216;x\u2212foobar&#8217;. <br \/> # Returns &#8216;text\/plain&#8217; as default, as per RFC 2045: <br \/> my ($type, $subtype) = split(&#8216;\/&#8217;, $field\u2212>type); <br \/> # Get generic information: <br \/> print $field\u2212>name; <br \/> # Get information related to &#8220;message&#8221; type: <br \/> if ($type eq &#8216;message&#8217;) { <br \/> print $field\u2212>id; <br \/> print $field\u2212>number; <br \/> print $field\u2212>total; <br \/> } <br \/> # Get information related to &#8220;multipart&#8221; type: <br \/> if ($type eq &#8216;multipart&#8217;) { <br \/> print $field\u2212>boundary; # the basic value, fixed up <br \/> print $field\u2212>multipart_boundary; # empty if not a multipart message! <br \/> } <br \/> # Get information related to &#8220;text&#8221; type: <br \/> if ($type eq &#8216;text&#8217;) { <br \/> print $field\u2212>charset; # returns &#8216;us\u2212ascii&#8217; as default <br \/> }<\/p>\n<h2>PUBLIC INTERFACE <a name=\"PUBLIC INTERFACE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">boundary<\/p>\n<p style=\"margin-left:17%;\">Return the boundary field. The boundary is returned exactly as given in the &#8220;Content\u2212type:&#8221; field; that is, the leading double-hyphen (&#8220;\u2212\u2212&#8221;) is <i>not<\/i> prepended.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">(Well, <i>almost<\/i> exactly&#8230; from <small>RFC 2046:<\/small><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">(If a boundary appears to end with white space, the white space <br \/> must be presumed to have been added by a gateway, and must be deleted.)<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">so we oblige and remove any trailing spaces.)<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">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>\n<p style=\"margin-left:11%;\">multipart_boundary<\/p>\n<p style=\"margin-left:17%;\">Like &#8220;boundary()&#8221;, except that this will also return the empty string if the message is not a multipart message. In other words, there\u2019s an automatic sanity check.<\/p>\n<p style=\"margin-left:11%;\">type<\/p>\n<p style=\"margin-left:17%;\">Try real hard to determine the content type (e.g., &#8220;text\/plain&#8221;, &#8220;image\/gif&#8221;, &#8220;x\u2212weird\u2212type&#8221;, which is returned in all-lowercase.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">A happy thing: the following code will work just as you would want, even if there\u2019s no subtype (as in &#8220;x\u2212weird\u2212type&#8221;)&#8230; in such a case, the $subtype would simply be the empty string:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">($type, $subtype) = split(&#8216;\/&#8217;, $head\u2212>mime_type);<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">If the content-type information is missing, it defaults to &#8220;text\/plain&#8221;, as per <small>RFC 2045:<\/small><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Default RFC 2822 messages are typed by this protocol as plain text in <br \/> the US\u2212ASCII character set, which can be explicitly specified as <br \/> &#8220;Content\u2212type: text\/plain; charset=us\u2212ascii&#8221;. If no Content\u2212Type is <br \/> specified, this default is assumed.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>Note:<\/b> under the &#8220;be liberal in what we accept&#8221; principle, this routine no longer syntax-checks the content type. If it ain\u2019t empty, just downcase and return it.<\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">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 &#8220;param()&#8221; method (which returns undef if the parameter is missing).<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">MIME::Field::ParamVal, Mail::Field<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Eryq (<i>eryq@zeegee.com<\/i>), ZeeGee Software Inc (<i>http:\/\/www.zeegee.com<\/i>). Dianne Skoll (dfs@roaringpenguin.com) http:\/\/www.roaringpenguin.com<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  MIME::Field::ContType \u2212 a &#8220;Content\u2212type&#8221; field <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3007,3126],"class_list":["post-6754","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-man3","tag-mimefieldconttype"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6754"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6754\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}