| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Courriel::Role::Part; |
|
2
|
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
3481
|
use strict; |
|
|
8
|
|
|
|
|
10
|
|
|
|
8
|
|
|
|
|
201
|
|
|
4
|
8
|
|
|
8
|
|
24
|
use warnings; |
|
|
8
|
|
|
|
|
9
|
|
|
|
8
|
|
|
|
|
151
|
|
|
5
|
8
|
|
|
8
|
|
28
|
use namespace::autoclean; |
|
|
8
|
|
|
|
|
9
|
|
|
|
8
|
|
|
|
|
39
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.42'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
455
|
use Courriel::Header::ContentType; |
|
|
8
|
|
|
|
|
9
|
|
|
|
8
|
|
|
|
|
126
|
|
|
10
|
8
|
|
|
8
|
|
26
|
use Courriel::Header::Disposition; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
132
|
|
|
11
|
8
|
|
|
8
|
|
24
|
use Courriel::Types qw( NonEmptyStr ); |
|
|
8
|
|
|
|
|
9
|
|
|
|
8
|
|
|
|
|
40
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
8
|
|
|
8
|
|
15066
|
use Moose::Role; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
55
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Courriel::Role::Streams'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
requires qw( _stream_content ); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has headers => ( |
|
20
|
|
|
|
|
|
|
is => 'rw', |
|
21
|
|
|
|
|
|
|
writer => '_set_headers', |
|
22
|
|
|
|
|
|
|
does => 'Courriel::Headers', |
|
23
|
|
|
|
|
|
|
required => 1, |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has container => ( |
|
27
|
|
|
|
|
|
|
is => 'rw', |
|
28
|
|
|
|
|
|
|
writer => '_set_container', |
|
29
|
|
|
|
|
|
|
isa => 'Courriel::Part::Multipart', |
|
30
|
|
|
|
|
|
|
weak_ref => 1, |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has content_type => ( |
|
34
|
|
|
|
|
|
|
is => 'ro', |
|
35
|
|
|
|
|
|
|
isa => 'Courriel::Header::ContentType', |
|
36
|
|
|
|
|
|
|
lazy => 1, |
|
37
|
|
|
|
|
|
|
builder => '_build_content_type', |
|
38
|
|
|
|
|
|
|
predicate => '_has_content_type', |
|
39
|
|
|
|
|
|
|
handles => [qw( mime_type charset has_charset )], |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
after BUILD => sub { |
|
43
|
|
|
|
|
|
|
my $self = shift; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->_maybe_set_content_type_in_headers; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return; |
|
48
|
|
|
|
|
|
|
}; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
after _set_headers => sub { |
|
51
|
|
|
|
|
|
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$self->_maybe_set_content_type_in_headers; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return; |
|
56
|
|
|
|
|
|
|
}; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _maybe_set_content_type_in_headers { |
|
59
|
159
|
|
|
159
|
|
146
|
my $self = shift; |
|
60
|
|
|
|
|
|
|
|
|
61
|
159
|
100
|
|
|
|
4397
|
return unless $self->_has_content_type; |
|
62
|
|
|
|
|
|
|
|
|
63
|
52
|
|
|
|
|
1075
|
$self->headers->replace( 'Content-Type' => $self->content_type ); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
|
67
|
|
|
|
|
|
|
sub _stream_to { |
|
68
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
69
|
0
|
|
|
|
|
0
|
my $output = shift; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
$self->headers->stream_to( output => $output ); |
|
72
|
0
|
|
|
|
|
0
|
$output->($Courriel::Helpers::CRLF); |
|
73
|
0
|
|
|
|
|
0
|
$self->_stream_content($output); |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
0
|
return; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
## use critic; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
{ |
|
80
|
|
|
|
|
|
|
my $fake_ct = Courriel::Header::ContentType->new_from_value( |
|
81
|
|
|
|
|
|
|
name => 'Content-Type', |
|
82
|
|
|
|
|
|
|
value => 'text/plain' |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _build_content_type { |
|
86
|
42
|
|
|
42
|
|
47
|
my $self = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
42
|
|
|
|
|
1035
|
my @ct = $self->headers->get('Content-Type'); |
|
89
|
42
|
50
|
|
|
|
107
|
if ( @ct > 1 ) { |
|
90
|
0
|
|
|
|
|
0
|
die 'This part defines more than one Content-Type header.'; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
42
|
|
66
|
|
|
981
|
return $ct[0] // $fake_ct; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |