| 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::Transport; | ||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 3 | $VERSION = '3.27'; | |||||||||||||||||||||||||||
| 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'
MC/DC0%0/1
$args->{'charset'} || 'UTF-8'
$args->{'charset'}
Truth table50%1/2
A
A= $args->{'charset'}
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 2 | ▶ | my $addr = $args->{address} || 'http://localhost'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'address'} || 'http://localhost'
MC/DC0%0/1
$args->{'address'} || 'http://localhost'
$args->{'address'}
Truth table50%1/2
A
A= $args->{'address'}
| |||||||||||||||||||||||||||||
| 32 | 2 | ▶ | my @addrs = ref $addr eq 'ARRAY' ? @$addr : $addr; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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'
MC/DC0%0/1
$args{'kind'} || 'request-response'
$args{'kind'}
Truth table50%1/2
A
A= $args{'kind'}
| |||||||||||||||||||||||||||||
| 59 | 2 | ▶ | my $format = $args{xml_format} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{'xml_format'} || 0
MC/DC0%0/1
$args{'xml_format'} || 0
$args{'xml_format'}
Truth table50%1/2
A
A= $args{'xml_format'}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 75 | 0 | { $trace->{errors} = [ $@->wasFatal ]; | |||||||||||||||||||||||||||
| 76 | 0 | return; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 2 | my $xmlin; | |||||||||||||||||||||||||||
| 80 | 2 | ▶ | if($textin) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 2 | ▶ | { $xmlin = try { XML::LibXML->load_xml(string => $$textin) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 82 | 2 | ▶ | if($@) { $trace->{errors} = [ $@->wasFatal ] } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 2 | else { $trace->{response_dom} = $xmlin } | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 2 | my $answer = $xmlin; | |||||||||||||||||||||||||||
| 87 | 2 | ▶ | if($kind eq 'one-way') | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 88 | 0 | { my $response = $trace->{http_response}; | |||||||||||||||||||||||||||
| 89 | 0 | ▶ | my $code = defined $response ? $response->code : -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if($code==202) { $answer ||= {} } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$answer ||= {}
MC/DC0%0/1
$answer ||= {}
$answer
Truth table0%0/2
A
A= $answer
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
wantarray or not keys %$xops
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
| |||||||||||||||||||||||||||||
| 107 | or warning "loosing received XOPs"; | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 2 | ▶ | wantarray ? ($answer, $xops) : $answer; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||