← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:12 2021

Filename/usr/local/lib/perl5/site_perl/MIME/Field/ContType.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sMIME::Field::ContType::::BEGIN@59MIME::Field::ContType::BEGIN@59
0000s0sMIME::Field::ContType::::BEGIN@60MIME::Field::ContType::BEGIN@60
0000s0sMIME::Field::ContType::::BEGIN@61MIME::Field::ContType::BEGIN@61
0000s0sMIME::Field::ContType::::boundaryMIME::Field::ContType::boundary
0000s0sMIME::Field::ContType::::charsetMIME::Field::ContType::charset
0000s0sMIME::Field::ContType::::idMIME::Field::ContType::id
0000s0sMIME::Field::ContType::::multipart_boundaryMIME::Field::ContType::multipart_boundary
0000s0sMIME::Field::ContType::::nameMIME::Field::ContType::name
0000s0sMIME::Field::ContType::::numberMIME::Field::ContType::number
0000s0sMIME::Field::ContType::::totalMIME::Field::ContType::total
0000s0sMIME::Field::ContType::::typeMIME::Field::ContType::type
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package MIME::Field::ContType;
2
3
4=head1 NAME
5
6MIME::Field::ContType - a "Content-type" field
7
8
9=head1 DESCRIPTION
10
11A subclass of Mail::Field.
12
13I<Don't use this class directly... its name may change in the future!>
14Instead, ask Mail::Field for new instances based on the field name!
15
16
17=head1 SYNOPSIS
18
19 use Mail::Field;
20 use MIME::Head;
21
22 # Create an instance from some text:
23 $field = Mail::Field->new('Content-type',
24 'text/HTML; charset="US-ASCII"');
25
26 # Get the MIME type, like 'text/plain' or 'x-foobar'.
27 # Returns 'text/plain' as default, as per RFC 2045:
28 my ($type, $subtype) = split('/', $field->type);
29
30 # Get generic information:
31 print $field->name;
32
33 # Get information related to "message" type:
34 if ($type eq 'message') {
35 print $field->id;
36 print $field->number;
37 print $field->total;
38 }
39
40 # Get information related to "multipart" type:
41 if ($type eq 'multipart') {
42 print $field->boundary; # the basic value, fixed up
43 print $field->multipart_boundary; # empty if not a multipart message!
44 }
45
46 # Get information related to "text" type:
47 if ($type eq 'text') {
48 print $field->charset; # returns 'us-ascii' as default
49 }
50
51
52=head1 PUBLIC INTERFACE
53
54=over 4
55
56=cut
57
58require 5.001;
59use strict;
60use MIME::Field::ParamVal;
61use vars qw($VERSION @ISA);
62
63@ISA = qw(MIME::Field::ParamVal);
64
65# The package version, both in 1.23 style *and* usable by MakeMaker:
66$VERSION = "5.509";
67
68# Install it:
69bless([])->register('Content-type');
70
71#------------------------------
72#
73# Basic access/storage methods...
74#
75sub charset {
76 lc(shift->paramstr('charset', @_)) || 'us-ascii'; # RFC 2045
77}
78sub id {
79 shift->paramstr('id', @_);
80}
81sub name {
82 shift->paramstr('name', @_);
83}
84sub number {
85 shift->paramstr('number', @_);
86}
87sub total {
88 shift->paramstr('total', @_);
89}
90
91
92#------------------------------
93
94=item boundary
95
96Return the boundary field. The boundary is returned exactly
97as given in the C<Content-type:> field; that is, the leading
98double-hyphen (C<-->) is I<not> prepended.
99
100(Well, I<almost> exactly... from RFC 2046:
101
102 (If a boundary appears to end with white space, the white space
103 must be presumed to have been added by a gateway, and must be deleted.)
104
105so we oblige and remove any trailing spaces.)
106
107Returns the empty string if there is no boundary, or if the boundary is
108illegal (e.g., if it is empty after all trailing whitespace has been
109removed).
110
111=cut
112
113sub boundary {
114 my $value = shift->param('boundary', @_);
115 defined($value) || return '';
116 $value =~ s/\s+$//; # kill trailing white, per RFC 2046
117 $value;
118}
119
120#------------------------------
121
122=item multipart_boundary
123
124Like C<boundary()>, except that this will also return the empty
125string if the message is not a multipart message. In other words,
126there's an automatic sanity check.
127
128=cut
129
130sub multipart_boundary {
131 my $self = shift;
132 my ($type) = split('/', $self->type);
133 return '' if ($type ne 'multipart'); # not multipart!
134 $self->boundary; # okay, return the boundary
135}
136
137#------------------------------
138
139=item type
140
141Try real hard to determine the content type (e.g., C<"text/plain">,
142C<"image/gif">, C<"x-weird-type">, which is returned
143in all-lowercase.
144
145A happy thing: the following code will work just as you would want,
146even if there's no subtype (as in C<"x-weird-type">)... in such a case,
147the $subtype would simply be the empty string:
148
149 ($type, $subtype) = split('/', $head->mime_type);
150
151If the content-type information is missing, it defaults to C<"text/plain">,
152as per RFC 2045:
153
154 Default RFC 2822 messages are typed by this protocol as plain text in
155 the US-ASCII character set, which can be explicitly specified as
156 "Content-type: text/plain; charset=us-ascii". If no Content-Type is
157 specified, this default is assumed.
158
159B<Note:> under the "be liberal in what we accept" principle, this routine
160no longer syntax-checks the content type. If it ain't empty,
161just downcase and return it.
162
163=cut
164
165sub type {
166 lc(shift->paramstr('_', @_)) || 'text/plain'; # RFC 2045
167}
168
169#------------------------------
170
171=back
172
173
174=head1 NOTES
175
176Since nearly all (if not all) parameters must have non-empty values
177to be considered valid, we just return the empty string to signify
178missing fields. If you need to get the I<real> underlying value,
179use the inherited C<param()> method (which returns undef if the
180parameter is missing).
181
182=head1 SEE ALSO
183
184L<MIME::Field::ParamVal>, L<Mail::Field>
185
186=head1 AUTHOR
187
188Eryq (F<eryq@zeegee.com>), ZeeGee Software Inc (F<http://www.zeegee.com>).
189Dianne Skoll (dfs@roaringpenguin.com) http://www.roaringpenguin.com
190
191=cut
192
1931;
194
- -