| 1 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||||
| 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.02. | ||||||||||||||||||||||||||||
| 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 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | $VERSION = '3.27'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use Log::Report 'xml-compile-soap'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use XML::Compile::SOAP::Util qw/:xop10/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use HTTP::Message (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use File::Slurper qw/read_binary write_binary/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Encode qw/decode FB_CROAK/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 2 | use overload '""' => 'content' | |||||||||||||||||||||||||||
| 25 | 2 | ▶ | , fallback => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | sub new(@) | ||||||||||||||||||||||||||||
| 29 | 4 | ▶ | { my ($class, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | $args{bytes} = \(delete $args{bytes}) | ||||||||||||||||||||||||||||
| 31 | 4 | ▶ | if defined $args{bytes} && ref $args{bytes} ne 'SCALAR'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $args{"bytes"} and ref $args{"bytes"} ne "SCALAR"
MC/DC50%1/2
defined $args{"bytes"} and ref $args{"bytes"} ne "SCALAR"
defined $args{"bytes"}
ref $args{"bytes"} ne "SCALAR"
Truth table66%2/3
A and B
A= defined $args{"bytes"}B= ref $args{"bytes"} ne "SCALAR"
| |||||||||||||||||||||||||||||
| 32 | 4 | bless \%args, $class; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | sub fromMime($) | ||||||||||||||||||||||||||||
| 37 | 2 | ▶ | { my ($class, $http) = @_; | ||||||||||||||||||||||||||
|
Subroutine
fromMime: called CC=4 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 2 | ▶ | my $cid = $http->header('Content-ID') || '<NONE>'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$http->header('Content-ID') || '<NONE>'
MC/DC0%0/1
$http->header('Content-ID') || '<NONE>'
$http->header('Content-ID')
Truth table50%1/2
A
A= $http->header('Content-ID')
| |||||||||||||||||||||||||||||
| 40 | 2 | ▶ | if($cid !~ s/^\s*\<(.*?)\>\s*$/$1/ ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | { warning __x"part has illegal Content-ID: `{cid}'", cid => $cid; | |||||||||||||||||||||||||||
| 42 | 0 | return (); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 2 | ▶ | my $content = $http->decoded_content(ref => 1) || $http->content(ref => 1); | ||||||||||||||||||||||||||
|
Condition33%1/3
$http->decoded_content('ref', 1) || $http->content('ref', 1)
MC/DC0%0/2
$http->decoded_content('ref', 1) || $http->content('ref', 1)
$http->decoded_content('ref', 1)
$http->content('ref', 1)
Truth table33%1/3
A || B
A= $http->decoded_content('ref', 1)B= $http->content('ref', 1)
| |||||||||||||||||||||||||||||
| 46 | 2 | $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 | ▶ | sub cid { shift->{cid} } | ||||||||||||||||||||||||||
|
Subroutine
cid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | sub content(;$) | ||||||||||||||||||||||||||||
| 59 | 15 | ▶ | { my ($self, $byref) = @_; | ||||||||||||||||||||||||||
|
Subroutine
content: called CC=4 SCAR=18.6
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 15 | ▶ | unless($self->{bytes}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | { my $f = $self->{file}; | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | my $bytes = try { read_binary $f }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | fault "failed reading XOP file {fn}", fn => $f if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | $self->{bytes} = \$bytes; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 15 | ▶ | $byref ? $self->{bytes} : ${$self->{bytes}}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | sub string() { | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
string: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my $cs = $self->contentCharset || 'UTF-8'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->contentCharset || 'UTF-8'
MC/DC0%0/1
$self->contentCharset || 'UTF-8'
$self->contentCharset
Truth table0%0/2
A
A= $self->contentCharset
| |||||||||||||||||||||||||||||
| 73 | 0 | decode $cs, $self->content, FB_CROAK; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub contentType() { shift->{type} } | ||||||||||||||||||||||||||
|
Subroutine
contentType: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub contentCharset() { shift->{charset} } | ||||||||||||||||||||||||||
|
Subroutine
contentCharset: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | #--------- | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | sub xmlNode($$$$) | ||||||||||||||||||||||||||||
| 83 | 1 | ▶ | { my ($self, $doc, $path, $tag) = @_; | ||||||||||||||||||||||||||
|
Subroutine
xmlNode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | 1 | my $node = $doc->createElement($tag); | |||||||||||||||||||||||||||
| 85 | 1 | $node->setNamespace($self->{xmime}, 'xmime', 0); | |||||||||||||||||||||||||||
| 86 | 1 | $node->setAttributeNS($self->{xmime}, contentType => $self->{type}); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 1 | my $include = $node->addChild($doc->createElement('Include')); | |||||||||||||||||||||||||||
| 89 | 1 | $include->setNamespace($self->{xop}, 'xop', 1); | |||||||||||||||||||||||||||
| 90 | 1 | $include->setAttribute(href => 'cid:'.$self->{cid}); | |||||||||||||||||||||||||||
| 91 | 1 | $node; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | sub mimePart(;$) | ||||||||||||||||||||||||||||
| 96 | 2 | ▶ | { my ($self, $headers) = @_; | ||||||||||||||||||||||||||
|
Subroutine
mimePart: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | 2 | my $mime = HTTP::Message->new($headers); | |||||||||||||||||||||||||||
| 98 | $mime->header | ||||||||||||||||||||||||||||
| 99 | ( Content_Type => $self->{type} | ||||||||||||||||||||||||||||
| 100 | , Content_Transfer_Encoding => 'binary' | ||||||||||||||||||||||||||||
| 101 | 2 | , Content_ID => '<'.$self->{cid}.'>' | |||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 2 | $mime->content_ref($self->content(1)); | |||||||||||||||||||||||||||
| 105 | 2 | $mime; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | sub write($) | ||||||||||||||||||||||||||||
| 110 | 0 | ▶ | { my ($self, $file) = @_; | ||||||||||||||||||||||||||
|
Subroutine
write: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 111 | 0 | write_binary $file, $self->content(1); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 2 | 1; | |||||||||||||||||||||||||||