| 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::SOAPHTTP; | ||||||||||||||||||||||||||||||||||||||
| 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::Transport'; | ||||||||||||||||||||||||||||||||||||
|
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 XML::Compile::SOAP::Util qw/SOAP11ENV SOAP11HTTP/; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use XML::Compile (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use LWP (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | use LWP::UserAgent (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | use HTTP::Request (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 26 | 3 | ▶ | use HTTP::Headers (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | # (Microsofts HTTP Extension Framework) | ||||||||||||||||||||||||||||||||||||||
| 30 | 3 | my $http_ext_id = SOAP11ENV; | |||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||
| 32 | 3 | my $mime_xop = 'application/xop+xml'; | |||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||
| 34 | 3 | __PACKAGE__->register(SOAP11HTTP); | |||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||
| 37 | sub init($) | ||||||||||||||||||||||||||||||||||||||
| 38 | 2 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 39 | 2 | $self->SUPER::init($args); | |||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||
| 41 | $self->userAgent | ||||||||||||||||||||||||||||||||||||||
| 42 | ( $args->{user_agent} | ||||||||||||||||||||||||||||||||||||||
| 43 | , keep_alive => (exists $args->{keep_alive} ? $args->{keep_alive} : 1) | ||||||||||||||||||||||||||||||||||||||
| 44 | 2 | ▶ | , timeout => ($args->{timeout} || 180) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$args->{'timeout'} || 180
MC/DC0%0/1
$args->{'timeout'} || 180
$args->{'timeout'}
Truth table50%1/2
A
A= $args->{'timeout'}
| |||||||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||||||
| 46 | 2 | $self; | |||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | sub initWSDL11($) | ||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | { my ($class, $wsdl) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
initWSDL11: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 51 | 0 | trace "initialize SOAPHTTP transporter for WSDL11"; | |||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||
| 54 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | 3 | my $default_ua; | |||||||||||||||||||||||||||||||||||||
| 58 | sub userAgent(;$) | ||||||||||||||||||||||||||||||||||||||
| 59 | 4 | ▶ | { my ($self, $agent) = (shift, shift); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
userAgent: called CC=4 SCAR=15.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | return $self->{user_agent} = $agent | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 61 | if defined $agent; | ||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||
| 63 | 4 | ▶ | $self->{user_agent} ||= $default_ua ||= LWP::UserAgent->new | ||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$self->{"user_agent"} ||= ($default_ua ||= "LWP::UserAgent"->new("requests_redirectable", ["GET", "HEAD", "POST", "M-POST"], "protocols_allowed", ["http", "https"], "parse_head", 0, @_))
$default_ua ||= "LWP::UserAgent"->new("requests_redirectable", ["GET", "HEAD", "POST", "M-POST"], "protocols_allowed", ["http", "https"], "parse_head", 0, @_)
MC/DC0%0/2
$self->{"user_agent"} ||= ($default_ua ||= "LWP::UserAgent"->new("requests_redirectable", ["GET", "HEAD", "POST", "M-POST"], "protocols_allowed", ["http", "https"], "parse_head", 0, @_))
$self->{"user_agent"}
($default_ua ||= "LWP::UserAgent"->new("requests_redirectable", ["GET", "HEAD", "POST", "M-POST"], "protocols_allowed", ["http", "https"], "parse_head", 0, @_))
MC/DC0%0/2
$default_ua ||= "LWP::UserAgent"->new("requests_redirectable", ["GET", "HEAD", "POST", "M-POST"], "protocols_allowed", ["http", "https"], "parse_head", 0, @_)
$default_ua
"LWP::UserAgent"->new("requests_redirectable", ["GET", "HEAD", "POST", "M-POST"], "protocols_allowed", ["http", "https"], "parse_head", 0, @_)
Truth table66%2/3
A ||= B
A= $self->{"user_agent"}B= ($default_ua ||= "LWP::UserAgent"->new("requests_redirectable", ["GET", "HEAD", "POST", "M-POST"], "protocols_allowed", ["http", "https"], "parse_head", 0, @_))
Truth table33%1/3
A ||= B
A= $default_uaB= "LWP::UserAgent"->new("requests_redirectable", ["GET", "HEAD", "POST", "M-POST"], "protocols_allowed", ["http", "https"], "parse_head", 0, @_)
| |||||||||||||||||||||||||||||||||||||||
| 64 | ( requests_redirectable => [ qw/GET HEAD POST M-POST/ ] | ||||||||||||||||||||||||||||||||||||||
| 65 | , protocols_allowed => [ qw/http https/ ] | ||||||||||||||||||||||||||||||||||||||
| 66 | , parse_head => 0 | ||||||||||||||||||||||||||||||||||||||
| 67 | , @_ | ||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub defaultUserAgent() { $default_ua } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
defaultUserAgent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||
| 74 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||
| 77 | # SUPER::compileClient() calls this method to do the real work | ||||||||||||||||||||||||||||||||||||||
| 78 | sub _prepare_call($) | ||||||||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_call: called CC=22 SCAR=43.9
| |||||||||||||||||||||||||||||||||||||||
| 80 | 2 | ▶ | 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'}
| |||||||||||||||||||||||||||||||||||||||
| 81 | 2 | ▶ | 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'}
| |||||||||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | my $version = ref $soap ? $soap->version : $soap; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 83 | 2 | ▶ | 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'}
| |||||||||||||||||||||||||||||||||||||||
| 84 | 2 | my $action = $args->{action}; | |||||||||||||||||||||||||||||||||||||
| 85 | 2 | my $mime = $args->{mime}; | |||||||||||||||||||||||||||||||||||||
| 86 | 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'}
| |||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | 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'
| |||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||
| 89 | 2 | my $charset = $self->charset; | |||||||||||||||||||||||||||||||||||||
| 90 | 2 | my $ua = $self->userAgent; | |||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||
| 92 | # Prepare header | ||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||
| 94 | 2 | $self->headerAddVersions($header); | |||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||
| 96 | # There is probably never a real HTTP server on the other side, but | ||||||||||||||||||||||||||||||||||||||
| 97 | # HTTP/1.1 requires this. | ||||||||||||||||||||||||||||||||||||||
| 98 | $header->header(Host => $1) | ||||||||||||||||||||||||||||||||||||||
| 99 | 2 | ▶ | if +($args->{endpoint} // '') =~ m!^\w+\://([^/:]+)!; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$args->{"endpoint"} // ""
MC/DC0%0/1
$args->{"endpoint"} // ""
$args->{"endpoint"}
Truth table50%1/2
A
A= $args->{"endpoint"}
| |||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||
| 101 | 2 | my $content_type; | |||||||||||||||||||||||||||||||||||||
| 102 | 2 | ▶ | if($version eq 'SOAP11') | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 103 | 2 | ▶ | { $mime ||= 'text/xml'; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$mime ||= "text/xml"
MC/DC0%0/1
$mime ||= "text/xml"
$mime
Truth table50%1/2
A
A= $mime
| |||||||||||||||||||||||||||||||||||||||
| 104 | 2 | $content_type = qq{$mime; charset=$charset}; | |||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||
| 106 | elsif($version eq 'SOAP12') | ||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | { $mime ||= 'application/soap+xml'; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$mime ||= "application/soap+xml"
MC/DC0%0/1
$mime ||= "application/soap+xml"
$mime
Truth table0%0/2
A
A= $mime
| |||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | my $sa = defined $action ? qq{; action="$action"} : ''; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $content_type = qq{$mime; charset=$charset$sa}; | |||||||||||||||||||||||||||||||||||||
| 110 | 0 | $header->header(Accept => $mime); # not the HTML answer | |||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||
| 112 | else | ||||||||||||||||||||||||||||||||||||||
| 113 | 0 | { error "SOAP version {version} not implemented", version => $version; | |||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | if($method eq 'POST') | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 117 | { # should only be used by SOAP11, but you never know. So, SOAP12 | ||||||||||||||||||||||||||||||||||||||
| 118 | # will have the action both ways. | ||||||||||||||||||||||||||||||||||||||
| 119 | 2 | ▶ | $header->header(SOAPAction => qq{"$action"}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 120 | if defined $action; | ||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||
| 122 | elsif($method eq 'M-POST') | ||||||||||||||||||||||||||||||||||||||
| 123 | 0 | { $header->header(Man => qq{"$http_ext_id"; ns=$mpost_id}); | |||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | $header->header("$mpost_id-SOAPAction", qq{"$action"}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 125 | if $version eq 'SOAP11'; | ||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||
| 127 | else | ||||||||||||||||||||||||||||||||||||||
| 128 | 0 | { error "SOAP method must be POST or M-POST, not {method}" | |||||||||||||||||||||||||||||||||||||
| 129 | , method => $method; | ||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||
| 132 | # Prepare request | ||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||
| 134 | # Ideally, we should change server when one fails, and stick to that | ||||||||||||||||||||||||||||||||||||||
| 135 | # one as long as possible. | ||||||||||||||||||||||||||||||||||||||
| 136 | 2 | my $server = $self->address; | |||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||
| 138 | # Create handler | ||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||
| 140 | my ($create_message, $parse_message) | ||||||||||||||||||||||||||||||||||||||
| 141 | 2 | ▶ | = exists $INC{'XML/Compile/XOP.pm'} | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 142 | ? $self->_prepare_xop_call($content_type) | ||||||||||||||||||||||||||||||||||||||
| 143 | : $self->_prepare_simple_call($content_type); | ||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||
| 145 | 2 | ▶ | $parse_message = $self->_prepare_for_no_answer($parse_message) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 146 | unless $expect; | ||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||
| 148 | 2 | my $hook = $args->{hook}; | |||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||
| 150 | $hook | ||||||||||||||||||||||||||||||||||||||
| 151 | ? sub # hooked code | ||||||||||||||||||||||||||||||||||||||
| 152 | 2 | ▶ | { my $trace = $_[1]; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.1
| |||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||
| 154 | 2 | my $request = HTTP::Request->new($method => $server, $header); | |||||||||||||||||||||||||||||||||||||
| 155 | 2 | $request->protocol('HTTP/1.1'); | |||||||||||||||||||||||||||||||||||||
| 156 | 2 | $create_message->($request, $_[0], $_[2]); | |||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||
| 158 | 2 | $trace->{http_request} = $request; | |||||||||||||||||||||||||||||||||||||
| 159 | 2 | $trace->{action} = $action; | |||||||||||||||||||||||||||||||||||||
| 160 | 2 | $trace->{soap_version} = $version; | |||||||||||||||||||||||||||||||||||||
| 161 | 2 | $trace->{server} = $server; | |||||||||||||||||||||||||||||||||||||
| 162 | 2 | $trace->{user_agent} = $ua; | |||||||||||||||||||||||||||||||||||||
| 163 | 2 | $trace->{hooked} = 1; | |||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||
| 165 | 2 | ▶ | my $response = $hook->($request, $trace, $self) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 166 | or return undef; | ||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||
| 168 | 2 | ▶ | UNIVERSAL::isa($response, 'HTTP::Response') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 169 | or error __x"transport_hook must produce a HTTP::Response, got {resp}" | ||||||||||||||||||||||||||||||||||||||
| 170 | , resp => $response; | ||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||
| 172 | 2 | $trace->{http_response} = $response; | |||||||||||||||||||||||||||||||||||||
| 173 | 2 | ▶ | if($response->is_error) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | { error $response->message | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 175 | if $response->header('Client-Warning'); | ||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||
| 177 | 0 | warning $response->message; | |||||||||||||||||||||||||||||||||||||
| 178 | # still try to parse the response for Fault blocks | ||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||
| 181 | 2 | $parse_message->($response); | |||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||
| 184 | : sub # real call | ||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | { my $trace = $_[1]; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $request = HTTP::Request->new($method => $server, $header); | |||||||||||||||||||||||||||||||||||||
| 188 | 0 | $request->protocol('HTTP/1.1'); | |||||||||||||||||||||||||||||||||||||
| 189 | 0 | $create_message->($request, $_[0], $_[2]); | |||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $trace->{http_request} = $request; | |||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | my $response = $ua->request($request) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 194 | or return undef; | ||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $trace->{http_response} = $response; | |||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if($response->is_error) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | { error $response->message | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 200 | if $response->header('Client-Warning'); | ||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||
| 202 | 0 | warning $response->message; | |||||||||||||||||||||||||||||||||||||
| 203 | # still try to parse the response for Fault blocks | ||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $parse_message->($response); | |||||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||
| 210 | sub _prepare_simple_call($) | ||||||||||||||||||||||||||||||||||||||
| 211 | 2 | ▶ | { my ($self, $content_type) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_simple_call: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||
| 213 | my $create = sub | ||||||||||||||||||||||||||||||||||||||
| 214 | 1 | ▶ | { my ($request, $content) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 215 | 1 | $request->header(Content_Type => $content_type); | |||||||||||||||||||||||||||||||||||||
| 216 | 1 | $request->content_ref($content); # already bytes (not utf-8) | |||||||||||||||||||||||||||||||||||||
| 217 | 3 | ▶ | use bytes; $request->header('Content-Length' => length $$content); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 218 | 2 | }; | |||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||
| 220 | my $parse = sub | ||||||||||||||||||||||||||||||||||||||
| 221 | 1 | ▶ | { my $response = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||
| 222 | 1 | ▶ | UNIVERSAL::isa($response, 'HTTP::Response') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 223 | or error __x"no response object received"; | ||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||
| 225 | 1 | ▶ | my $ct = $response->content_type || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$response->content_type || ''
MC/DC0%0/1
$response->content_type || ''
$response->content_type
Truth table50%1/2
A
A= $response->content_type
| |||||||||||||||||||||||||||||||||||||||
| 226 | 1 | ▶ | lc($ct) ne 'multipart/related' | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 227 | or error __x"remote system uses XOP, use XML::Compile::XOP"; | ||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||
| 229 | 1 | trace "received ".$response->status_line; | |||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||
| 231 | 1 | ▶ | $ct =~ m,[/+]xml$,i | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 232 | or error __x"answer is not xml but `{type}'", type => $ct; | ||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||
| 234 | # HTTP::Message::decoded_content() does not work for old Perls | ||||||||||||||||||||||||||||||||||||||
| 235 | 1 | ▶ | my $content = $response->decoded_content(ref => 1) | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$response->decoded_content('ref', 1) || $response->content('ref', 1)
MC/DC0%0/2
$response->decoded_content('ref', 1) || $response->content('ref', 1)
$response->decoded_content('ref', 1)
$response->content('ref', 1)
Truth table33%1/3
A || B
A= $response->decoded_content('ref', 1)B= $response->content('ref', 1)
| |||||||||||||||||||||||||||||||||||||||
| 236 | || $response->content(ref => 1); | ||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||
| 238 | 1 | ($content, {}); | |||||||||||||||||||||||||||||||||||||
| 239 | 2 | }; | |||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||
| 241 | 2 | ($create, $parse); | |||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||
| 244 | sub _prepare_xop_call($) | ||||||||||||||||||||||||||||||||||||||
| 245 | 1 | ▶ | { my ($self, $content_type) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_xop_call: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||
| 247 | 1 | my ($simple_create, $simple_parse) | |||||||||||||||||||||||||||||||||||||
| 248 | = $self->_prepare_simple_call($content_type); | ||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||
| 250 | 1 | my $charset = $self->charset; | |||||||||||||||||||||||||||||||||||||
| 251 | my $create = sub | ||||||||||||||||||||||||||||||||||||||
| 252 | 1 | ▶ | { my ($request, $content, $mtom) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||
| 253 | 1 | ▶ | $mtom ||= []; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$mtom ||= []
MC/DC0%0/1
$mtom ||= []
$mtom
Truth table50%1/2
A
A= $mtom
| |||||||||||||||||||||||||||||||||||||||
| 254 | 1 | ▶ | @$mtom or return $simple_create->($request, $content); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||
| 256 | 1 | my $bound = "MIME-boundary-".int rand 10000; | |||||||||||||||||||||||||||||||||||||
| 257 | 1 | (my $start_cid = $mtom->[0]->cid) =~ s/^.*\@/xml@/; | |||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||
| 259 | 1 | my $si = "$content_type"; | |||||||||||||||||||||||||||||||||||||
| 260 | 1 | $si =~ s/\"/\\"/g; | |||||||||||||||||||||||||||||||||||||
| 261 | 1 | $request->header(Content_Type => <<__CT); | |||||||||||||||||||||||||||||||||||||
| 262 | multipart/related; | ||||||||||||||||||||||||||||||||||||||
| 263 | boundary="$bound"; | ||||||||||||||||||||||||||||||||||||||
| 264 | type="$mime_xop"; | ||||||||||||||||||||||||||||||||||||||
| 265 | start="<$start_cid>"; | ||||||||||||||||||||||||||||||||||||||
| 266 | start-info="$si" | ||||||||||||||||||||||||||||||||||||||
| 267 | __CT | ||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||
| 269 | 1 | my $base = HTTP::Message->new | |||||||||||||||||||||||||||||||||||||
| 270 | ( [ Content_Type => qq{$mime_xop; charset="$charset"; type="$si"} | ||||||||||||||||||||||||||||||||||||||
| 271 | , Content_Transfer_Encoding => '8bit' | ||||||||||||||||||||||||||||||||||||||
| 272 | , Content_ID => "<$start_cid>" | ||||||||||||||||||||||||||||||||||||||
| 273 | ] ); | ||||||||||||||||||||||||||||||||||||||
| 274 | 1 | $base->content_ref($content); # already bytes (not utf-8) | |||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||
| 276 | 1 | my @parts = ($base, map $_->mimePart, @$mtom); | |||||||||||||||||||||||||||||||||||||
| 277 | 1 | $request->parts(@parts); #$base, map $_->mimePart, @$mtom); | |||||||||||||||||||||||||||||||||||||
| 278 | 1 | $request; | |||||||||||||||||||||||||||||||||||||
| 279 | 1 | }; | |||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||
| 281 | my $parse = sub | ||||||||||||||||||||||||||||||||||||||
| 282 | 1 | ▶ | { my ($response, $mtom) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=23.8
| |||||||||||||||||||||||||||||||||||||||
| 283 | 1 | ▶ | my $ct = $response->header('Content-Type') || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$response->header('Content-Type') || ''
MC/DC0%0/1
$response->header('Content-Type') || ''
$response->header('Content-Type')
Truth table50%1/2
A
A= $response->header('Content-Type')
| |||||||||||||||||||||||||||||||||||||||
| 284 | 1 | ▶ | $ct =~ m!^\s*multipart/related\s*\;!i | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 285 | or return $simple_parse->($response); | ||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||
| 287 | 1 | my (@parts, %parts); | |||||||||||||||||||||||||||||||||||||
| 288 | 1 | foreach my $part ($response->parts) | |||||||||||||||||||||||||||||||||||||
| 289 | 2 | ▶ | { my $include = XML::Compile::XOP::Include->fromMime($part) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 290 | or next; | ||||||||||||||||||||||||||||||||||||||
| 291 | 2 | $parts{$include->cid} = $include; | |||||||||||||||||||||||||||||||||||||
| 292 | 2 | push @parts, $include; | |||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||
| 295 | @parts | ||||||||||||||||||||||||||||||||||||||
| 296 | 1 | ▶ | or error "no parts in response multi-part for XOP"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||
| 298 | 1 | my $root; | |||||||||||||||||||||||||||||||||||||
| 299 | 1 | ▶ | if($ct =~ m!start\=(["']?)\<([^"']*)\>\1!) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 300 | 1 | { my $startid = $2; | |||||||||||||||||||||||||||||||||||||
| 301 | 1 | $root = delete $parts{$startid}; | |||||||||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | defined $root | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 303 | or warning __x"cannot find root node id in parts `{id}'" | ||||||||||||||||||||||||||||||||||||||
| 304 | , id => $startid; | ||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||
| 306 | 1 | ▶ | unless($root) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 307 | 0 | { $root = shift @parts; | |||||||||||||||||||||||||||||||||||||
| 308 | 0 | delete $parts{$root->cid}; | |||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||
| 311 | 1 | ($root->content(1), \%parts); | |||||||||||||||||||||||||||||||||||||
| 312 | 1 | }; | |||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||
| 314 | 1 | ($create, $parse); | |||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||
| 317 | sub _prepare_for_no_answer($) | ||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_for_no_answer: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 319 | sub | ||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | { my $response = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | my $ct = $response->content_type || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$response->content_type || ''
MC/DC0%0/1
$response->content_type || ''
$response->content_type
Truth table0%0/2
A
A= $response->content_type
| |||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||
| 323 | 0 | trace "received ".$response->status_line; | |||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $content = ''; | |||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if($ct =~ m,[/+]xml$,i) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 327 | { # HTTP::Message::decoded_content() does not work for old Perls | ||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | $content = $] >= 5.008 ? $response->decoded_content(ref => 1) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 329 | : $response->content(ref => 1); | ||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ($content, {}); | |||||||||||||||||||||||||||||||||||||
| 333 | 0 | }; | |||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||
| 337 | sub headerAddVersions($) | ||||||||||||||||||||||||||||||||||||||
| 338 | 2 | ▶ | { my ($thing, $h) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
headerAddVersions: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 339 | 2 | foreach my $pkg (qw/XML::Compile XML::Compile::Cache | |||||||||||||||||||||||||||||||||||||
| 340 | XML::Compile::SOAP XML::LibXML LWP/) | ||||||||||||||||||||||||||||||||||||||
| 341 | 3 | ▶ | { no strict 'refs'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 342 | 10 | ▶ | 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";}
| |||||||||||||||||||||||||||||||||||||||
| 343 | 10 | (my $field = "X-$pkg-Version") =~ s/\:\:/-/g; | |||||||||||||||||||||||||||||||||||||
| 344 | 10 | $h->header($field => $version); | |||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||
| 348 | 3 | 1; | |||||||||||||||||||||||||||||||||||||