line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Courriel::Role::Part; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
5113
|
use strict; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
267
|
|
4
|
8
|
|
|
8
|
|
48
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
242
|
|
5
|
8
|
|
|
8
|
|
40
|
use namespace::autoclean; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
60
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.43'; |
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
679
|
use Courriel::Header::ContentType; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
246
|
|
10
|
8
|
|
|
8
|
|
36
|
use Courriel::Header::Disposition; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
200
|
|
11
|
8
|
|
|
8
|
|
36
|
use Courriel::Types qw( NonEmptyStr ); |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
61
|
|
12
|
|
|
|
|
|
|
|
13
|
8
|
|
|
8
|
|
21208
|
use Moose::Role; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
80
|
|
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
|
|
202
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
159
|
100
|
|
|
|
6117
|
return unless $self->_has_content_type; |
62
|
|
|
|
|
|
|
|
63
|
52
|
|
|
|
|
1552
|
$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
|
|
106
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
42
|
|
|
|
|
1406
|
my @ct = $self->headers->get('Content-Type'); |
89
|
42
|
50
|
|
|
|
142
|
if ( @ct > 1 ) { |
90
|
0
|
|
|
|
|
0
|
die 'This part defines more than one Content-Type header.'; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
42
|
|
66
|
|
|
1369
|
return $ct[0] // $fake_ct; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |