lib/XML/Compile/Transport.pm

filter: Statementstmt 80.2% 69 / 86 Branchbran 41.6% 10 / 24 Conditioncond 38.4% 5 / 13 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 80.0% 16 / 20 Podpod 62.5% 5 / 8 totaltotal 66.4% 105 / 158 CC 19 SCAR 24.1
CC
19
Cov
68%
__ANON__
28.4
init
4.2
compileClient
3.7
CRAP 11.1
« lib/XML/Compile/SOAP.pm ↑ Summary lib/XML/Compile/SOAP/Extension.pm »
1 # Copyrights 2007-2022 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.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::Transport;
10 3 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 $VERSION = '3.28';
12  
13 3 ▶use base 'XML::Compile::SOAP::Extension';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 3 ▶use Log::Report 'xml-compile-soap';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 3 ▶use Log::Report::Exception ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 3 ▶use XML::LibXML ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23 3 ▶use Time::HiRes qw/time/;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25  
26 sub init($)
27 2 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=4 SCAR=14.3
Pod undocumented
28 2 $self->SUPER::init($args);
29 2 ▶ $self->{charset} = $args->{charset} || 'UTF-8';
Condition50%1/2
$args->{'charset'} || 'UTF-8'
l!l
02
MC/DC0%0/1
$args->{'charset'} || 'UTF-8'
$args->{'charset'}
Truth table50%1/2
A
A= $args->{'charset'}
Aresult
11
00
30  
31 2 ▶ my $addr = $args->{address} || 'http://localhost';
Condition50%1/2
$args->{'address'} || 'http://localhost'
l!l
02
MC/DC0%0/1
$args->{'address'} || 'http://localhost'
$args->{'address'}
Truth table50%1/2
A
A= $args->{'address'}
Aresult
11
00
32 2 ▶ my @addrs = ref $addr eq 'ARRAY' ? @$addr : $addr;
Branch: 1 branch
BranchTrueFalseTotal
ref $addr eq 'ARRAY' ? : 0 2 2
33  
34 2 $self->{addrs} = \@addrs;
35 2 $self;
36 }
37  
38 #-------------------------------------
39  
40  
41 3 ▶sub charset() {shift->{charset}}
Subroutine charset: called CC=1 SCAR=0.0
Pod documented
42  
43  
44 0 ▶sub addresses() { @{shift->{addrs}} }
Subroutine addresses: not called CC=1 SCAR=6.9
Pod documented
45  
46  
47 sub address()
48 2 ▶{ my $addrs = shift->{addrs};
Subroutine address: called CC=2 SCAR=7.2
Pod documented
49 2 ▶ @$addrs==1 ? $addrs->[0] : $addrs->[rand @$addrs];
Branch: 1 branch
BranchTrueFalseTotal
@$addrs == 1 ? : 2 0 2
50 }
51  
52 #-------------------------------------
53  
54  
55 sub compileClient(@)
56 2 ▶{ my ($self, %args) = @_;
Subroutine compileClient: called CC=3 SCAR=13.0
Pod documented
57 2 my $call = $self->_prepare_call(\%args);
58 2 ▶ my $kind = $args{kind} || 'request-response';
Condition50%1/2
$args{'kind'} || 'request-response'
l!l
02
MC/DC0%0/1
$args{'kind'} || 'request-response'
$args{'kind'}
Truth table50%1/2
A
A= $args{'kind'}
Aresult
11
00
59 2 ▶ my $format = $args{xml_format} || 0;
Condition50%1/2
$args{'xml_format'} || 0
l!l
02
MC/DC0%0/1
$args{'xml_format'} || 0
$args{'xml_format'}
Truth table50%1/2
A
A= $args{'xml_format'}
Aresult
11
00
60  
61 sub
62 2 ▶ { my ($xmlout, $trace, $mtom) = @_;
Subroutine __ANON__: called CC=13 SCAR=33.5
63 2 my $start = time;
64 2 ▶ my $textout = ref $xmlout ? $xmlout->toString($format) : $xmlout;
Branch: 1 branch
BranchTrueFalseTotal
ref $xmlout ? : 2 0 2
65 #warn $xmlout->toString(1); # show message sent
66  
67 2 my $stringify = time;
68 2 $trace->{stringify_elapse} = $stringify - $start;
69 2 $trace->{transport_start} = $start;
70  
71 2 ▶ my ($textin, $xops) = try { $call->(\$textout, $trace, $mtom) };
Subroutine __ANON__: called CC=1 SCAR=0.0
72 2 my $connected = time;
73 2 $trace->{connect_elapse} = $connected - $stringify;
74 2 ▶ if($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 2 2
75 0 { $trace->{errors} = [ $@->wasFatal ];
76 0 return;
77 }
78  
79 2 my $xmlin;
80 2 ▶ if($textin)
Branch: 1 branch
BranchTrueFalseTotal
if ($textin) 2 0 2
81 2 ▶ { $xmlin = try { XML::LibXML->load_xml(string => $$textin) };
Subroutine __ANON__: called CC=1 SCAR=0.0
82 0 ▶ if($@) { $trace->{errors} = [ $@->wasFatal ] }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 2 2
83 2 else { $trace->{response_dom} = $xmlin }
84 }
85  
86 2 my $answer = $xmlin;
87 2 ▶ if($kind eq 'one-way')
Branch: 2 branches
BranchTrueFalseTotal
if ($kind eq 'one-way') { } 0 2 2
elsif (not $xmlin) { } 0 2 2
88 0 { my $response = $trace->{http_response};
89 0 ▶ my $code = defined $response ? $response->code : -1;
Branch: 1 branch
BranchTrueFalseTotal
defined $response ? : 0 0 0
90 0 ▶ if($code==202) { $answer ||= {} }
Branch: 1 branch
BranchTrueFalseTotal
if ($code == 202) { } 0 0 0
Condition0%0/2
$answer ||= {}
l!l
00
MC/DC0%0/1
$answer ||= {}
$answer
Truth table0%0/2
A
A= $answer
Aresult
11
00
91 else
92 0 { push @{$trace->{errors}}, Log::Report::Exception->new
93 (reason => 'error', message => __"call failed with code $code")
94 }
95 }
96 elsif(!$xmlin)
97 0 { push @{$trace->{errors}}, Log::Report::Exception->new
98 (reason => 'error', message => __"no xml as answer");
99 }
100  
101 2 my $end = $trace->{transport_end} = time;
102  
103 2 $trace->{parse_elapse} = $end - $connected;
104 2 $trace->{transport_elapse} = $end - $start;
105  
106 2 ▶ wantarray || ! keys %$xops
Branch: 1 branch
BranchTrueFalseTotal
wantarray or not keys %$xops or &warning("loosing received XOPs") 2 0 2
Condition33%1/3
wantarray or not keys %$xops
l!l&&r!l&&!r
200
MC/DC0%0/2
wantarray or not keys %$xops
wantarray not keys %$xops
Truth table33%1/3
A or not(B)
A= wantarrayB= not keys %$xops
ABresult
1X1
011
000
107 or warning "loosing received XOPs";
108  
109 2 ▶ wantarray ? ($answer, $xops) : $answer;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 0 2
110 }
111 2 }
112  
113 0 ▶sub _prepare_call($) { panic "not implemented" }
Subroutine _prepare_call: not called CC=1 SCAR=6.9
114  
115 #--------------------------------------
116  
117  
118 3 { my %registered;
119 3 ▶ sub register($) { my ($class, $uri) = @_; $registered{$uri} = $class }
Subroutine register: called CC=1 SCAR=0.0
Pod documented
120 0 ▶ sub plugin($) { my ($class, $uri) = @_; $registered{$uri} }
Subroutine plugin: not called CC=1 SCAR=6.9
Pod undocumented
121 0 ▶ sub registered($) { values %registered }
Subroutine registered: not called CC=1 SCAR=6.9
Pod undocumented
122 }
123  
124 #--------------------------------------
125  
126  
127 3 1;
« lib/XML/Compile/SOAP.pm ↑ Summary lib/XML/Compile/SOAP/Extension.pm »