| 1 | # Copyrights 2016-2020 by [Mark Overmeer <markov@overmeer.net>]. | ||||||||||||||||||||||||||||
| 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-Mojolicious. | ||||||||||||||||||||||||||||
| 6 | # Meta-POD processed 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::SOAPHTTP_MojoUA; | ||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | $VERSION = '0.06'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use base 'XML::Compile::Transport'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Log::Report 'xml-compile-soap-mojolicious'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use XML::Compile::Transport::SOAPHTTP (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 23 | # code mixin from XML::Compile::Transport::SOAPHTTP | ||||||||||||||||||||||||||||
| 24 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 2 | foreach (qw/_prepare_xop_call _prepare_simple_call _prepare_for_no_answer/) { | |||||||||||||||||||||||||||
| 26 | 6 | *{ __PACKAGE__ . "::$_" } = \&{"XML::Compile::Transport::SOAPHTTP::$_"}; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | ▶ | use XML::Compile::SOAP::Util qw/SOAP11ENV SOAP11HTTP/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 2 | ▶ | use XML::Compile (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 2 | ▶ | use Mojolicious (); # only for version info?! | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 2 | ▶ | use Mojo::UserAgent (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | 2 | ▶ | use Mojo::IOLoop (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | 2 | ▶ | use HTTP::Request (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | 2 | ▶ | use HTTP::Response (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | 2 | ▶ | use HTTP::Headers (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 39 | 2 | ▶ | use Scalar::Util qw(blessed reftype); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # (Microsofts HTTP Extension Framework) | ||||||||||||||||||||||||||||
| 42 | 2 | my $http_ext_id = SOAP11ENV; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 2 | __PACKAGE__->register(SOAP11HTTP); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1 | ▶ | sub init($) { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=12.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | 1 | my ($self, $args) = @_; | |||||||||||||||||||||||||||
| 49 | 1 | ▶ | if(my $cb = $self->{ua_start_cb} = delete $args->{ua_start_callback}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | panic "callback not a code" if reftype $cb ne 'CODE'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 1 | $self->{mojo_ua} = $args->{mojo_ua}; | |||||||||||||||||||||||||||
| 54 | 1 | $self->SUPER::init($args); | |||||||||||||||||||||||||||
| 55 | 1 | $self; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub initWSDL11($) { | ||||||||||||||||||||||||||
|
Subroutine
initWSDL11: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 59 | 0 | my ($class, $wsdl) = @_; | |||||||||||||||||||||||||||
| 60 | 0 | trace "initialize SOAPHTTP-MojoUA transporter for WSDL11"; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | ▶ | sub uaStartCallback { shift->{ua_start_cb} } | ||||||||||||||||||||||||||
|
Subroutine
uaStartCallback: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 1 | ▶ | sub compileClient(@) { | ||||||||||||||||||||||||||
|
Subroutine
compileClient: called CC=2 SCAR=8.3
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 1 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||
| 73 | 1 | my $call = $self->_prepare_call( \%args ); | |||||||||||||||||||||||||||
| 74 | 1 | ▶ | 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'}
| |||||||||||||||||||||||||||||
| 75 | 1 | my $parser = XML::LibXML->new; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 1 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.7
| |||||||||||||||||||||||||||||
| 78 | 1 | my ($xmlout, $trace, $mtom, $callback) = @_; | |||||||||||||||||||||||||||
| 79 | 1 | my $start = time; | |||||||||||||||||||||||||||
| 80 | 1 | ▶ | my $textout = ref $xmlout ? $xmlout->toString : $xmlout; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | #warn $xmlout->toString(1); # show message sent | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 1 | my $stringify = time; | |||||||||||||||||||||||||||
| 85 | 1 | $trace->{transport_start} = $start; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 1 | ▶ | my $handler = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=31.2
| |||||||||||||||||||||||||||||
| 88 | 1 | my ($textin, $xops) = @_; | |||||||||||||||||||||||||||
| 89 | 1 | my $connected = time; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 1 | my $xmlin; | |||||||||||||||||||||||||||
| 92 | 1 | ▶ | if($textin) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 0 | $xmlin = eval { $parser->parse_string($$textin) }; | |||||||||||||||||||||||||||
| 94 | 0 | ▶ | $trace->{error} = $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 1 | my $answer; | |||||||||||||||||||||||||||
| 98 | 1 | ▶ | if($kind eq 'one-way') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 99 | 0 | my $response = $trace->{http_response}; | |||||||||||||||||||||||||||
| 100 | 0 | ▶ | my $code = defined $response ? $response->code : -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if($code == 202) { $answer = $xmlin || {} } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$xmlin || {}
MC/DC0%0/1
$xmlin || {}
$xmlin
Truth table0%0/2
A
A= $xmlin
| |||||||||||||||||||||||||||||
| 102 | 0 | else { $trace->{error} = "call failed with code $code" } | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | 0 | elsif($xmlin) { $answer = $xmlin } | |||||||||||||||||||||||||||
| 105 | 1 | ▶ | else { $trace->{error} ||= 'no xml as answer' } | ||||||||||||||||||||||||||
|
Condition50%1/2
$trace->{"error"} ||= "no xml as answer"
MC/DC0%0/1
$trace->{"error"} ||= "no xml as answer"
$trace->{"error"}
Truth table50%1/2
A
A= $trace->{"error"}
| |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 1 | my $end = $trace->{transport_end} = time; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 1 | $trace->{stringify_elapse} = $stringify - $start; | |||||||||||||||||||||||||||
| 110 | 1 | $trace->{connect_elapse} = $connected - $stringify; | |||||||||||||||||||||||||||
| 111 | 1 | $trace->{parse_elapse} = $end - $connected; | |||||||||||||||||||||||||||
| 112 | 1 | $trace->{transport_elapse} = $end - $start; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 1 | return ( $answer, $trace, $xops ); | |||||||||||||||||||||||||||
| 115 | 1 | }; | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 1 | ▶ | $call->( \$textout, $trace, $mtom, sub { $callback->( $handler->(@_) ) } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 118 | 1 | }; | |||||||||||||||||||||||||||
| 119 | } ## end sub compileClient(@) | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 1 | ▶ | sub _prepare_call($) { | ||||||||||||||||||||||||||
|
Subroutine
_prepare_call: called CC=23 SCAR=40.7
| |||||||||||||||||||||||||||||
| 123 | 1 | my ($self, $args) = @_; | |||||||||||||||||||||||||||
| 124 | 1 | ▶ | my $method = $args->{method} || 'POST'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'method'} || 'POST'
MC/DC0%0/1
$args->{'method'} || 'POST'
$args->{'method'}
Truth table50%1/2
A
A= $args->{'method'}
| |||||||||||||||||||||||||||||
| 125 | 1 | ▶ | my $soap = $args->{soap} || 'SOAP11'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'soap'} || 'SOAP11'
MC/DC0%0/1
$args->{'soap'} || 'SOAP11'
$args->{'soap'}
Truth table50%1/2
A
A= $args->{'soap'}
| |||||||||||||||||||||||||||||
| 126 | 1 | ▶ | my $version = ref $soap ? $soap->version : $soap; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 1 | ▶ | my $mpost_id = $args->{mpost_id} || 42; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'mpost_id'} || 42
MC/DC0%0/1
$args->{'mpost_id'} || 42
$args->{'mpost_id'}
Truth table50%1/2
A
A= $args->{'mpost_id'}
| |||||||||||||||||||||||||||||
| 128 | 1 | my $action = $args->{action}; | |||||||||||||||||||||||||||
| 129 | 1 | my $mime = $args->{mime}; | |||||||||||||||||||||||||||
| 130 | 1 | ▶ | 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'}
| |||||||||||||||||||||||||||||
| 131 | 1 | ▶ | my $expect = $kind ne 'one-way' && $kind ne 'notification-operation'; | ||||||||||||||||||||||||||
|
Condition33%1/3
$kind ne 'one-way' && $kind ne 'notification-operation'
MC/DC0%0/2
$kind ne 'one-way' && $kind ne 'notification-operation'
$kind ne 'one-way'
$kind ne 'notification-operation'
Truth table33%1/3
A && B
A= $kind ne 'one-way'B= $kind ne 'notification-operation'
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 1 | my $charset = $self->charset; | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | # Prepare header | ||||||||||||||||||||||||||||
| 136 | 1 | ▶ | my $header = $args->{header} || HTTP::Headers->new; | ||||||||||||||||||||||||||
|
Condition33%1/3
$args->{'header'} || 'HTTP::Headers'->new
MC/DC0%0/2
$args->{'header'} || 'HTTP::Headers'->new
$args->{'header'}
'HTTP::Headers'->new
Truth table33%1/3
A || B
A= $args->{'header'}B= 'HTTP::Headers'->new
| |||||||||||||||||||||||||||||
| 137 | 1 | $self->headerAddVersions($header); | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 1 | my $content_type; | |||||||||||||||||||||||||||
| 140 | 1 | ▶ | if($version eq 'SOAP11') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 141 | 1 | ▶ | $mime ||= ref $soap ? $soap->mimeType : 'text/xml'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$mime ||= ref $soap ? $soap->mimeType : "text/xml"
MC/DC0%0/2
$mime ||= ref $soap ? $soap->mimeType : "text/xml"
$mime
ref $soap ? $soap->mimeType : "text/xml"
Truth table33%1/3
A ||= B
A= $mimeB= ref $soap ? $soap->mimeType : "text/xml"
| |||||||||||||||||||||||||||||
| 142 | 1 | $content_type = qq{$mime; charset=$charset}; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | elsif($version eq 'SOAP12') { | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $mime ||= ref $soap ? $soap->mimeType : 'application/soap+xml'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mime ||= ref $soap ? $soap->mimeType : "application/soap+xml"
MC/DC0%0/2
$mime ||= ref $soap ? $soap->mimeType : "application/soap+xml"
$mime
ref $soap ? $soap->mimeType : "application/soap+xml"
Truth table0%0/3
A ||= B
A= $mimeB= ref $soap ? $soap->mimeType : "application/soap+xml"
| |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $sa = defined $action ? qq{; action="$action"} : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | $content_type = qq{$mime; charset=$charset$sa}; | |||||||||||||||||||||||||||
| 148 | 0 | $header->header( Accept => $mime ); # not the HTML answer | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | else { | ||||||||||||||||||||||||||||
| 151 | 0 | error __x"SOAP version {version} not implemented", version => $version; | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 1 | ▶ | if($method eq 'POST') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 155 | 1 | ▶ | $header->header( SOAPAction => qq{"$action"} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | if defined $action; | ||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | elsif($method eq 'M-POST') { | ||||||||||||||||||||||||||||
| 159 | 0 | $header->header( Man => qq{"$http_ext_id"; ns=$mpost_id} ); | |||||||||||||||||||||||||||
| 160 | 0 | ▶ | $header->header( "$mpost_id-SOAPAction", qq{"$action"} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | if $version eq 'SOAP11'; | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | else { | ||||||||||||||||||||||||||||
| 164 | 0 | error __x"SOAP method must be POST or M-POST, not {method}" | |||||||||||||||||||||||||||
| 165 | , method => $method; | ||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | # Prepare request | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | # Ideally, we should change server when one fails, and stick to that | ||||||||||||||||||||||||||||
| 171 | # one as long as possible. | ||||||||||||||||||||||||||||
| 172 | 1 | my $server = $self->address; | |||||||||||||||||||||||||||
| 173 | 1 | my $request = HTTP::Request->new( | |||||||||||||||||||||||||||
| 174 | $method => $server, | ||||||||||||||||||||||||||||
| 175 | $header | ||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||
| 177 | 1 | $request->protocol('HTTP/1.1'); | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | # Create handler | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | my ($create_message, $parse_message) | ||||||||||||||||||||||||||||
| 182 | 1 | ▶ | = exists $INC{'XML/Compile/XOP.pm'} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | ? $self->_prepare_xop_call($content_type) | ||||||||||||||||||||||||||||
| 184 | : $self->_prepare_simple_call($content_type); | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 1 | ▶ | $parse_message = $self->_prepare_for_no_answer($parse_message) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | unless $expect; | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | # Needs to be outside the sub so it does not go out of scope | ||||||||||||||||||||||||||||
| 190 | # when the sub is left (which would cause the termination of | ||||||||||||||||||||||||||||
| 191 | # the request) | ||||||||||||||||||||||||||||
| 192 | 1 | ▶ | my $ua = $self->{mojo_ua} || Mojo::UserAgent->new; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'mojo_ua'} || 'Mojo::UserAgent'->new
MC/DC0%0/2
$self->{'mojo_ua'} || 'Mojo::UserAgent'->new
$self->{'mojo_ua'}
'Mojo::UserAgent'->new
Truth table33%1/3
A || B
A= $self->{'mojo_ua'}B= 'Mojo::UserAgent'->new
| |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 1 | ▶ | if(my $callback = $self->uaStartCallback) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | $ua->on(start => $callback); | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | # async call | ||||||||||||||||||||||||||||
| 199 | 1 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||
| 200 | 1 | my ( $content, $trace, $mtom, $callback ) = @_; | |||||||||||||||||||||||||||
| 201 | 1 | $create_message->($request, $content, $mtom); | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 1 | $trace->{http_request} = $request; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 1 | ▶ | my $handler = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=27.0
| |||||||||||||||||||||||||||||
| 206 | 1 | my $tx = shift; | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 1 | ▶ | unless(blessed $tx && $tx->isa('Mojo::Transaction::HTTP')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($tx) and $tx->isa("Mojo::Transaction::HTTP")
MC/DC0%0/2
builtin::blessed($tx) and $tx->isa("Mojo::Transaction::HTTP")
builtin::blessed($tx)
$tx->isa("Mojo::Transaction::HTTP")
Truth table33%1/3
A and B
A= builtin::blessed($tx)B= $tx->isa("Mojo::Transaction::HTTP")
| |||||||||||||||||||||||||||||
| 209 | 0 | $trace->{error} = "Did not receive a transaction object"; | |||||||||||||||||||||||||||
| 210 | 0 | return $callback->(undef, undef, $trace); | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 1 | my $res = $tx->res; | |||||||||||||||||||||||||||
| 214 | 1 | my $headers = $res->headers->to_hash(1); | |||||||||||||||||||||||||||
| 215 | 1 | foreach my $h ( keys %{$headers} ) { | |||||||||||||||||||||||||||
| 216 | 5 | ▶ | if ( reftype $headers->{$h} eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | 5 | $headers->{$h} = join ', ', @{$headers->{$h}}; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 1 | my $err = $res->error; | |||||||||||||||||||||||||||
| 222 | $headers->{'Client-Warning'} = 'Client side error: '.$err->{message} | ||||||||||||||||||||||||||||
| 223 | 1 | ▶ | if $err && !$err->{code}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$err and not $err->{"code"}
MC/DC0%0/2
$err and not $err->{"code"}
$err
not $err->{"code"}
Truth table33%1/3
A and not(B)
A= $errB= not $err->{"code"}
| |||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 1 | my $response = $trace->{http_response} = HTTP::Response->new( | |||||||||||||||||||||||||||
| 226 | $res->code, $res->message, [%$headers], $res->body | ||||||||||||||||||||||||||||
| 227 | ); | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 1 | ▶ | if($response->header('Client-Warning')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | 0 | $trace->{error} = $response->message; | |||||||||||||||||||||||||||
| 231 | 0 | return $callback->(undef, undef, $trace); | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 1 | ▶ | if($response->is_error) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 1 | $trace->{error} = $response->message; | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | # still try to parse the response for Fault blocks | ||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 1 | ▶ | my ($parsed, $mtom) = try { $parse_message->($response) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 241 | 1 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 1 | $trace->{error} = $@->wasFatal->message; | |||||||||||||||||||||||||||
| 243 | 1 | return $callback->(undef, undef, $trace); | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | ▶ | try { $callback->($parsed, $mtom, $trace) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 247 | 1 | }; | |||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 1 | my $tx = $ua->build_tx($request->method => $request->uri->as_string); | |||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 1 | foreach my $hdr_name ($request->headers->header_field_names) { | |||||||||||||||||||||||||||
| 252 | 7 | ▶ | next if $hdr_name eq "Content-Length"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 6 | foreach my $hdr ( $request->headers->header($hdr_name) ) { | |||||||||||||||||||||||||||
| 255 | 6 | $tx->req->headers->append( $hdr_name => $hdr ); | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | 1 | $tx->req->body($request->content); | |||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | $ua->start( | ||||||||||||||||||||||||||||
| 261 | 1 | ▶ | $tx => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 262 | 1 | my ($ua, $tx) = @_; | |||||||||||||||||||||||||||
| 263 | 1 | $handler->($tx); | |||||||||||||||||||||||||||
| 264 | }, | ||||||||||||||||||||||||||||
| 265 | 1 | ); | |||||||||||||||||||||||||||
| 266 | 1 | }; | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 1 | ▶ | sub headerAddVersions($) { | ||||||||||||||||||||||||||
|
Subroutine
headerAddVersions: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 272 | 1 | my ( $thing, $h ) = @_; | |||||||||||||||||||||||||||
| 273 | 1 | foreach my $pkg ( | |||||||||||||||||||||||||||
| 274 | qw/XML::Compile | ||||||||||||||||||||||||||||
| 275 | XML::Compile::Cache | ||||||||||||||||||||||||||||
| 276 | XML::Compile::SOAP | ||||||||||||||||||||||||||||
| 277 | XML::LibXML | ||||||||||||||||||||||||||||
| 278 | Mojolicious/ ) | ||||||||||||||||||||||||||||
| 279 | { | ||||||||||||||||||||||||||||
| 280 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 281 | 5 | ▶ | my $version = ${"${pkg}::VERSION"} || 'undef'; | ||||||||||||||||||||||||||
|
Condition50%1/2
${"${pkg}::VERSION";} || 'undef'
MC/DC0%0/1
${"${pkg}::VERSION";} || 'undef'
${"${pkg}::VERSION";}
Truth table50%1/2
A
A= ${"${pkg}::VERSION";}
| |||||||||||||||||||||||||||||
| 282 | 5 | ( my $field = "X-$pkg-Version" ) =~ s/\:\:/-/g; | |||||||||||||||||||||||||||
| 283 | 5 | $h->header($field => $version); | |||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 2 | 1; | |||||||||||||||||||||||||||