line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2007-2022 by [Mark Overmeer ]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.03. |
5
|
|
|
|
|
|
|
# This code is part of distribution XML-Compile-SOAP. Meta-POD processed |
6
|
|
|
|
|
|
|
# with OODoc into POD and HTML manual-pages. See README.md |
7
|
|
|
|
|
|
|
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package XML::Compile::XOP::Include; |
10
|
2
|
|
|
2
|
|
11
|
use vars '$VERSION'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
138
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.28'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
16
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
54
|
|
15
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
45
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
11
|
use Log::Report 'xml-compile-soap'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
9
|
|
18
|
2
|
|
|
2
|
|
408
|
use XML::Compile::SOAP::Util qw/:xop10/; |
|
2
|
|
|
|
|
32
|
|
|
2
|
|
|
|
|
174
|
|
19
|
2
|
|
|
2
|
|
16
|
use HTTP::Message (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
54
|
|
20
|
2
|
|
|
2
|
|
796
|
use File::Slurper qw/read_binary write_binary/; |
|
2
|
|
|
|
|
5219
|
|
|
2
|
|
|
|
|
117
|
|
21
|
2
|
|
|
2
|
|
13
|
use Encode qw/decode FB_CROAK/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
85
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
12
|
use overload '""' => 'content' |
25
|
2
|
|
|
2
|
|
10
|
, fallback => 1; |
|
2
|
|
|
|
|
4
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new(@) |
29
|
4
|
|
|
4
|
1
|
518
|
{ my ($class, %args) = @_; |
30
|
|
|
|
|
|
|
$args{bytes} = \(delete $args{bytes}) |
31
|
4
|
100
|
66
|
|
|
25
|
if defined $args{bytes} && ref $args{bytes} ne 'SCALAR'; |
32
|
4
|
|
|
|
|
17
|
bless \%args, $class; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub fromMime($) |
37
|
2
|
|
|
2
|
1
|
5
|
{ my ($class, $http) = @_; |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
50
|
|
|
3
|
my $cid = $http->header('Content-ID') || ''; |
40
|
2
|
50
|
|
|
|
82
|
if($cid !~ s/^\s*\<(.*?)\>\s*$/$1/ ) |
41
|
0
|
|
|
|
|
0
|
{ warning __x"part has illegal Content-ID: `{cid}'", cid => $cid; |
42
|
0
|
|
|
|
|
0
|
return (); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
33
|
|
|
8
|
my $content = $http->decoded_content(ref => 1) || $http->content(ref => 1); |
46
|
2
|
|
|
|
|
653
|
$class->new |
47
|
|
|
|
|
|
|
( bytes => $content |
48
|
|
|
|
|
|
|
, cid => $cid |
49
|
|
|
|
|
|
|
, type => scalar $http->content_type |
50
|
|
|
|
|
|
|
, charset => scalar $http->content_type_charset |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
4
|
|
|
4
|
1
|
1184
|
sub cid { shift->{cid} } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub content(;$) |
59
|
15
|
|
|
15
|
1
|
1438
|
{ my ($self, $byref) = @_; |
60
|
15
|
50
|
|
|
|
97
|
unless($self->{bytes}) |
61
|
0
|
|
|
|
|
0
|
{ my $f = $self->{file}; |
62
|
0
|
|
|
0
|
|
0
|
my $bytes = try { read_binary $f }; |
|
0
|
|
|
|
|
0
|
|
63
|
0
|
0
|
|
|
|
0
|
fault "failed reading XOP file {fn}", fn => $f if $@; |
64
|
0
|
|
|
|
|
0
|
$self->{bytes} = \$bytes; |
65
|
|
|
|
|
|
|
} |
66
|
15
|
100
|
|
|
|
38
|
$byref ? $self->{bytes} : ${$self->{bytes}}; |
|
12
|
|
|
|
|
42
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub string() { |
71
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
72
|
0
|
|
0
|
|
|
0
|
my $cs = $self->contentCharset || 'UTF-8'; |
73
|
0
|
|
|
|
|
0
|
decode $cs, $self->content, FB_CROAK; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
0
|
1
|
0
|
sub contentType() { shift->{type} } |
78
|
0
|
|
|
0
|
1
|
0
|
sub contentCharset() { shift->{charset} } |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#--------- |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub xmlNode($$$$) |
83
|
1
|
|
|
1
|
1
|
3
|
{ my ($self, $doc, $path, $tag) = @_; |
84
|
1
|
|
|
|
|
6
|
my $node = $doc->createElement($tag); |
85
|
1
|
|
|
|
|
4
|
$node->setNamespace($self->{xmime}, 'xmime', 0); |
86
|
1
|
|
|
|
|
15
|
$node->setAttributeNS($self->{xmime}, contentType => $self->{type}); |
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
29
|
my $include = $node->addChild($doc->createElement('Include')); |
89
|
1
|
|
|
|
|
3
|
$include->setNamespace($self->{xop}, 'xop', 1); |
90
|
1
|
|
|
|
|
30
|
$include->setAttribute(href => 'cid:'.$self->{cid}); |
91
|
1
|
|
|
|
|
43
|
$node; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub mimePart(;$) |
96
|
2
|
|
|
2
|
1
|
1712
|
{ my ($self, $headers) = @_; |
97
|
2
|
|
|
|
|
13
|
my $mime = HTTP::Message->new($headers); |
98
|
|
|
|
|
|
|
$mime->header |
99
|
|
|
|
|
|
|
( Content_Type => $self->{type} |
100
|
|
|
|
|
|
|
, Content_Transfer_Encoding => 'binary' |
101
|
2
|
|
|
|
|
56
|
, Content_ID => '<'.$self->{cid}.'>' |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
|
|
310
|
$mime->content_ref($self->content(1)); |
105
|
2
|
|
|
|
|
40
|
$mime; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub write($) |
110
|
0
|
|
|
0
|
1
|
|
{ my ($self, $file) = @_; |
111
|
0
|
|
|
|
|
|
write_binary $file, $self->content(1); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |