line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Courriel::Role::Part; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
6089
|
use strict; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
256
|
|
4
|
8
|
|
|
8
|
|
33
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
286
|
|
5
|
8
|
|
|
8
|
|
42
|
use namespace::autoclean; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
73
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.44'; |
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
756
|
use Courriel::Header::ContentType; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
359
|
|
10
|
8
|
|
|
8
|
|
40
|
use Courriel::Header::Disposition; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
231
|
|
11
|
8
|
|
|
8
|
|
37
|
use Courriel::Types qw( NonEmptyStr ); |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
63
|
|
12
|
|
|
|
|
|
|
|
13
|
8
|
|
|
8
|
|
23241
|
use Moose::Role; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
76
|
|
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
|
|
199
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
159
|
100
|
|
|
|
6780
|
return unless $self->_has_content_type; |
62
|
|
|
|
|
|
|
|
63
|
52
|
|
|
|
|
1508
|
$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
|
|
87
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
42
|
|
|
|
|
1325
|
my @ct = $self->headers->get('Content-Type'); |
89
|
42
|
50
|
|
|
|
133
|
if ( @ct > 1 ) { |
90
|
0
|
|
|
|
|
0
|
die 'This part defines more than one Content-Type header.'; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
42
|
|
66
|
|
|
1477
|
return $ct[0] // $fake_ct; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |