lib/SOAP/Transport/HTTP.pm

filter: Statementstmt 66.4% 273 / 411 Branchbran 41.9% 89 / 212 Conditioncond 32.7% 55 / 168 MC/DCmcdc 3.5% 3 / 85 Subroutinesub 80.7% 46 / 57 Podpod n/a totaltotal 49.9% 466 / 933 CC 170 SCAR 42.6
CC
170
Cov
53%
send_receive
171.9
handle
127.1
handler
110.0
CRAP 70.9
« lib/SOAP/Test.pm ↑ Summary lib/SOAP/Transport/POP3.pm »
1 # ======================================================================
2 #
3 # Copyright (C) 2000-2004 Paul Kulchenko (paulclinger@yahoo.com)
4 # SOAP::Lite is free software; you can redistribute it
5 # and/or modify it under the same terms as Perl itself.
6 #
7 # ======================================================================
8  
9 package SOAP::Transport::HTTP;
10  
11 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 16 our $VERSION = 1.14;
14  
15 16 ▶use SOAP::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 16 ▶use SOAP::Packager;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 # ======================================================================
19  
20 package SOAP::Transport::HTTP::Client;
21  
22 16 ▶use vars qw(@ISA $COMPRESS $USERAGENT_CLASS);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 16 $USERAGENT_CLASS = 'LWP::UserAgent';
24 16 @ISA = qw(SOAP::Client);
25  
26 16 $COMPRESS = 'deflate';
27  
28 16 my ( %redirect, %mpost, %nocompress );
29  
30 # hack for HTTP connection that returns Keep-Alive
31 # miscommunication (?) between LWP::Protocol and LWP::Protocol::http
32 # dies after timeout, but seems like we could make it work
33 16 my $_patched = 0;
34  
35 sub patch {
36 15 ▶ return if $_patched;
Subroutine patch: called CC=2 SCAR=9.2
Branch: 1 branch
BranchTrueFalseTotal
if $_patched 1 14 15
37 16 ▶ BEGIN { local ($^W) = 0; }
Subroutine BEGIN: called CC=1 SCAR=0.0
38 {
39 14 local $^W = 0;
40 sub LWP::UserAgent::redirect_ok;
41 1 ▶ *LWP::UserAgent::redirect_ok = sub { 1 }
Subroutine __ANON__: called CC=1 SCAR=0.0
42 14 }
43 {
44  
45 14 package
46 LWP::Protocol;
47 14 local $^W = 0;
48 14 my $collect = \&collect; # store original
49 *collect = sub {
50 2 ▶ if ( defined $_[2]->header('Connection')
Subroutine __ANON__: called CC=5 SCAR=29.0
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[2]->header("Connection") and $_[2]->header("Connection") eq "Keep-Alive") 0 2 2
Condition33%1/3
defined $_[2]->header("Connection") and $_[2]->header("Connection") eq "Keep-Alive"
!ll&&!rl&&r
020
MC/DC0%0/2
defined $_[2]->header("Connection") and $_[2]->header("Connection") eq "Keep-Alive"
defined $_[2]->header("Connection") $_[2]->header("Connection") eq "Keep-Alive"
Truth table33%1/3
A and B
A= defined $_[2]->header("Connection")B= $_[2]->header("Connection") eq "Keep-Alive"
ABresult
0X0
100
111
51 && $_[2]->header('Connection') eq 'Keep-Alive' ) {
52 0 my $data = $_[3]->();
53 my $next =
54 $_[2]->header('Content-Length') &&
55 SOAP::Utils::bytelength($$data) ==
56 $_[2]->header('Content-Length')
57 0 ▶ ? sub { my $str = ''; \$str; }
Subroutine __ANON__: not called CC=1 SCAR=6.9
58 0 ▶ : $_[3];
Branch: 1 branch
BranchTrueFalseTotal
$_[2]->header('Content-Length') && SOAP::Utils::bytelength($$data) == $_[2]->header('Content-Length') ? : 0 0 0
Condition0%0/3
$_[2]->header("Content-Length") and SOAP::Utils::bytelength($$data) == $_[2]->header("Content-Length")
!ll&&!rl&&r
000
MC/DC0%0/2
$_[2]->header("Content-Length") and SOAP::Utils::bytelength($$data) == $_[2]->header("Content-Length")
$_[2]->header("Content-Length") SOAP::Utils::bytelength($$data) == $_[2]->header("Content-Length")
Truth table0%0/3
A and B
A= $_[2]->header("Content-Length")B= SOAP::Utils::bytelength($$data) == $_[2]->header("Content-Length")
ABresult
0X0
100
111
59 0 my $done = 0;
60 $_[3] = sub {
61 0 ▶ $done++ ? &$next : $data;
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$done++ ? : 0 0 0
62 0 };
63 }
64 2 goto &$collect;
65 14 };
66 }
67 14 $_patched++;
68 }
69  
70 15 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
71  
72 sub http_request {
73 30 ▶ my $self = shift;
Subroutine http_request: called CC=2 SCAR=6.9
74 30 ▶ if (@_) { $self->{'_http_request'} = shift; return $self }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 17 13 30
75 13 return $self->{'_http_request'};
76 }
77  
78 sub http_response {
79 184 ▶ my $self = shift;
Subroutine http_response: called CC=2 SCAR=6.9
80 184 ▶ if (@_) { $self->{'_http_response'} = shift; return $self }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 13 171 184
81 171 return $self->{'_http_response'};
82 }
83  
84 sub setDebugLogger {
85 16 ▶ my ($self,$logger) = @_;
Subroutine setDebugLogger: called CC=1 SCAR=0.0
86 16 $self->{debug_logger} = $logger;
87 }
88  
89 sub new {
90 17 ▶ my $class = shift;
Subroutine new: called CC=10 SCAR=23.1
91 #print "HTTP.pm DEBUG: in sub new\n";
92  
93 17 ▶ return $class if ref $class; # skip if we're already object...
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 1 16 17
94  
95 16 ▶ if ( !grep { $_ eq $USERAGENT_CLASS } @ISA ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $SOAP::Transport::HTTP::Client::USERAGENT_CLASS;} @SOAP::Transport::HTTP::Client::ISA) 14 2 16
96 14 push @ISA, $USERAGENT_CLASS;
97 }
98  
99 16 ▶ eval("require $USERAGENT_CLASS")
Branch: 1 branch
BranchTrueFalseTotal
eval "require $SOAP::Transport::HTTP::Client::USERAGENT_CLASS" or die "Could not load UserAgent class $SOAP::Transport::HTTP::Client::USERAGENT_CLASS: $@" 0 16 16
100 or die "Could not load UserAgent class $USERAGENT_CLASS: $@";
101  
102 16 require HTTP::Request;
103 16 require HTTP::Headers;
104  
105 16 ▶ patch() if $SOAP::Constants::PATCH_HTTP_KEEPALIVE;
Branch: 1 branch
BranchTrueFalseTotal
if $SOAP::Constants::PATCH_HTTP_KEEPALIVE 15 1 16
106  
107 16 my ( @params, @methods );
108 16 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 13 16 29
109 13 ▶ $class->can( $_[0] )
Branch: 1 branch
BranchTrueFalseTotal
$class->can($_[0]) ? : 13 0 13
110 ? push( @methods, shift() => shift )
111 : push( @params, shift );
112 }
113 16 my $self = $class->SUPER::new(@params);
114  
115 16 ▶ die
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa("LWP::UserAgent") 0 16 16
116 "SOAP::Transport::HTTP::Client must inherit from LWP::UserAgent, or one of its subclasses"
117 if !$self->isa("LWP::UserAgent");
118  
119 16 $self->agent( join '/', 'SOAP::Lite', 'Perl',
120 $SOAP::Transport::HTTP::VERSION );
121 16 $self->options( {} );
122  
123 16 $self->http_request( HTTP::Request->new() );
124  
125 16 ▶ while (@methods) {
Branch: 1 branch
BranchTrueFalseTotal
if (@methods) 13 16 29
126 13 my ( $method, $params ) = splice( @methods, 0, 2 );
127 13 ▶ $self->$method( ref $params eq 'ARRAY' ? @$params : $params );
Branch: 1 branch
BranchTrueFalseTotal
ref $params eq 'ARRAY' ? : 0 13 13
128 }
129  
130 16 SOAP::Trace::objects('()');
131  
132 16 $self->setDebugLogger(\&SOAP::Trace::debug);
133  
134 16 return $self;
135 }
136  
137 sub send_receive {
138 12 ▶ my ( $self, %parameters ) = @_;
Subroutine send_receive: called CC=42 SCAR=51.5
139 my ( $context, $envelope, $endpoint, $action, $encoding, $parts ) =
140 12 @parameters{qw(context envelope endpoint action encoding parts)};
141  
142 12 ▶ $encoding ||= 'UTF-8';
Condition100%2/2
$encoding ||= "UTF-8"
l!l
111
MC/DC100%1/1
$encoding ||= "UTF-8"
$encoding
Truth table100%2/2
A
A= $encoding
Aresult
11
00
143  
144 12 ▶ $endpoint ||= $self->endpoint;
Condition66%2/3
$endpoint ||= $self->endpoint
l!l&&r!l&&!r
1110
MC/DC0%0/2
$endpoint ||= $self->endpoint
$endpoint $self->endpoint
Truth table66%2/3
A ||= B
A= $endpointB= $self->endpoint
ABresult
1X1
011
000
145  
146 12 my $method = 'POST';
147 12 $COMPRESS = 'gzip';
148  
149 $self->options->{is_compress} ||=
150 exists $self->options->{compress_threshold}
151 12 ▶ && eval { require Compress::Zlib };
Condition33%2/6
$self->options->{"is_compress"} ||= exists $self->options->{"compress_threshold"} && eval { do { require Compress::Zlib } }
l!l&&r!l&&!r
0012
exists $self->options->{'compress_threshold'} && eval { do { require Compress::Zlib } }
!ll&&!rl&&r
1200
MC/DC0%0/3
$self->options->{"is_compress"} ||= exists $self->options->{"compress_threshold"} && eval { do { require Compress::Zlib } }
$self->options->{"is_compress"} exists $self->options->{'compress_threshold'} eval { do { require Compress::Zlib } }
Truth table0%0/4
A ||= B && C
A= $self->options->{"is_compress"}B= exists $self->options->{'compress_threshold'}C= eval { do { require Compress::Zlib } }
ABCresult
1XX1
0111
00X0
0100
152  
153 # Initialize the basic about the HTTP Request object
154 12 my $http_request = $self->http_request()->clone();
155  
156 # $self->http_request(HTTP::Request->new);
157 12 $http_request->headers( HTTP::Headers->new );
158  
159 # TODO - add application/dime
160 12 $http_request->header(
161 Accept => ['text/xml', 'multipart/*', 'application/soap'] );
162 12 $http_request->method($method);
163 12 $http_request->url($endpoint);
164  
165 16 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
166 12 ▶ if ($parts) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parts) 0 12 12
167 0 my $packager = $context->packager;
168 0 $envelope = $packager->package( $envelope, $context );
169 0 for my $hname ( keys %{$packager->headers_http} ) {
170 $http_request->headers->header(
171 0 $hname => $packager->headers_http->{$hname} );
172 }
173  
174 # TODO - DIME support
175 }
176  
177 COMPRESS: {
178 12 my $compressed =
179 !exists $nocompress{$endpoint}
180 && $self->options->{is_compress}
181 12 ▶ && ( $self->options->{compress_threshold} || 0 ) < length $envelope;
Condition25%2/8
!exists $nocompress{$endpoint} && $self->options->{'is_compress'} && ($self->options->{'compress_threshold'} || 0) < length $envelope
!ll&&!rl&&r
1200
not exists $nocompress{$endpoint} and $self->options->{"is_compress"}
!ll&&!rl&&r
0120
$self->options->{'compress_threshold'} || 0
l!l
00
MC/DC0%0/3
!exists $nocompress{$endpoint} && $self->options->{'is_compress'} && ($self->options->{'compress_threshold'} || 0) < length $envelope
not exists $nocompress{$endpoint} $self->options->{"is_compress"} $self->options->{'compress_threshold'}
Truth table25%1/4
not(A) and B && C
A= not exists $nocompress{$endpoint}B= $self->options->{"is_compress"}C= $self->options->{'compress_threshold'}
ABCresult
0XX0
10X0
1100
1111
182  
183  
184 12 my $original_encoding = $http_request->content_encoding;
185  
186 12 while (1) {
187  
188 # check cache for redirect
189 12 ▶ $endpoint = $redirect{$endpoint} if exists $redirect{$endpoint};
Branch: 1 branch
BranchTrueFalseTotal
if exists $redirect{$endpoint} 0 12 12
190  
191 # check cache for M-POST
192 12 ▶ $method = 'M-POST' if exists $mpost{$endpoint};
Branch: 1 branch
BranchTrueFalseTotal
if exists $mpost{$endpoint} 0 12 12
193  
194 # what's this all about?
195 # unfortunately combination of LWP and Perl 5.6.1 and later has bug
196 # in sending multibyte characters. LWP uses length() to calculate
197 # content-length header and starting 5.6.1 length() calculates chars
198 # instead of bytes. 'use bytes' in THIS file doesn't work, because
199 # it's lexically scoped. Unfortunately, content-length we calculate
200 # here doesn't work either, because LWP overwrites it with
201 # content-length it calculates (which is wrong) AND uses length()
202 # during syswrite/sysread, so we are in a bad shape anyway.
203 #
204 # what to do? we calculate proper content-length (using
205 # bytelength() function from SOAP::Utils) and then drop utf8 mark
206 # from string (doing pack with 'C0A*' modifier) if length and
207 # bytelength are not the same
208 12 my $bytelength = SOAP::Utils::bytelength($envelope);
209 12 ▶ if ($] < 5.008) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < 5.008) { } 0 12 12
210 0 $envelope = pack( 'C0A*', $envelope );
211 }
212 else {
213 12 require Encode;
214 12 $envelope = Encode::encode($encoding, $envelope);
215 }
216 # if !$SOAP::Constants::DO_NOT_USE_LWP_LENGTH_HACK
217 # && length($envelope) != $bytelength;
218  
219 # compress after encoding
220 # doing it before breaks the compressed content (#74577)
221 12 ▶ $envelope = Compress::Zlib::memGzip($envelope) if $compressed;
Branch: 1 branch
BranchTrueFalseTotal
if $compressed 0 12 12
222  
223 12 $http_request->content($envelope);
224 12 $http_request->protocol('HTTP/1.1');
225  
226 $http_request->proxy_authorization_basic( $ENV{'HTTP_proxy_user'},
227 $ENV{'HTTP_proxy_pass'} )
228 12 ▶ if ( $ENV{'HTTP_proxy_user'} && $ENV{'HTTP_proxy_pass'} );
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"HTTP_proxy_user"} and $ENV{"HTTP_proxy_pass"} 0 12 12
Condition33%1/3
$ENV{"HTTP_proxy_user"} and $ENV{"HTTP_proxy_pass"}
!ll&&!rl&&r
1200
MC/DC0%0/2
$ENV{"HTTP_proxy_user"} and $ENV{"HTTP_proxy_pass"}
$ENV{"HTTP_proxy_user"} $ENV{"HTTP_proxy_pass"}
Truth table33%1/3
A and B
A= $ENV{"HTTP_proxy_user"}B= $ENV{"HTTP_proxy_pass"}
ABresult
0X0
100
111
229  
230 # by Murray Nesbitt
231 12 ▶ if ( $method eq 'M-POST' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq 'M-POST') { } 0 12 12
232 0 my $prefix = sprintf '%04d', int( rand(1000) );
233 0 $http_request->header(
234 Man => qq!"$SOAP::Constants::NS_ENV"; ns=$prefix! );
235 0 ▶ $http_request->header( "$prefix-SOAPAction" => $action )
Branch: 1 branch
BranchTrueFalseTotal
if defined $action 0 0 0
236 if defined $action;
237 }
238 else {
239 12 ▶ $http_request->header( SOAPAction => $action )
Branch: 1 branch
BranchTrueFalseTotal
if defined $action 11 1 12
240 if defined $action;
241 }
242  
243 # $http_request->header(Expect => '100-Continue');
244  
245 # allow compress if present and let server know we could handle it
246 $http_request->header( 'Accept-Encoding' =>
247 [$SOAP::Transport::HTTP::Client::COMPRESS] )
248 12 ▶ if $self->options->{is_compress};
Branch: 1 branch
BranchTrueFalseTotal
if $self->options->{"is_compress"} 0 12 12
249  
250 12 ▶ $http_request->content_encoding(
Branch: 1 branch
BranchTrueFalseTotal
if $compressed 0 12 12
251 $SOAP::Transport::HTTP::Client::COMPRESS)
252 if $compressed;
253  
254 12 ▶ if ( !$http_request->content_type ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $http_request->content_type) { } 12 0 12
elsif (not $SOAP::Constants::DO_NOT_USE_CHARSET and $encoding) { } 0 0 0
255 12 ▶ $http_request->content_type(
Branch: 1 branch
BranchTrueFalseTotal
!$SOAP::Constants::DO_NOT_USE_CHARSET && $encoding ? : 11 1 12
Condition66%2/3
not $SOAP::Constants::DO_NOT_USE_CHARSET and $encoding
!ll&&!rl&&r
1011
MC/DC50%1/2
not $SOAP::Constants::DO_NOT_USE_CHARSET and $encoding
not $SOAP::Constants::DO_NOT_USE_CHARSET $encoding
Truth table66%2/3
not(A) and B
A= not $SOAP::Constants::DO_NOT_USE_CHARSETB= $encoding
ABresult
0X0
100
111
256 join '; ',
257 $SOAP::Constants::DEFAULT_HTTP_CONTENT_TYPE,
258 !$SOAP::Constants::DO_NOT_USE_CHARSET && $encoding
259 ? 'charset=' . lc($encoding)
260 : () );
261 }
262 ▶ elsif ( !$SOAP::Constants::DO_NOT_USE_CHARSET && $encoding ) {
Condition0%0/3
not $SOAP::Constants::DO_NOT_USE_CHARSET and $encoding
!ll&&!rl&&r
000
MC/DC0%0/2
not $SOAP::Constants::DO_NOT_USE_CHARSET and $encoding
not $SOAP::Constants::DO_NOT_USE_CHARSET $encoding
Truth table0%0/3
not(A) and B
A= not $SOAP::Constants::DO_NOT_USE_CHARSETB= $encoding
ABresult
0X0
100
111
263 0 my $tmpType = $http_request->headers->header('Content-type');
264  
265 # $http_request->content_type($tmpType.'; charset=' . lc($encoding));
266 0 my $addition = '; charset=' . lc($encoding);
267 0 ▶ $http_request->content_type( $tmpType . $addition )
Branch: 1 branch
BranchTrueFalseTotal
unless $tmpType =~ /$addition/ 0 0 0
268 if ( $tmpType !~ /$addition/ );
269 }
270  
271 12 $http_request->content_length($bytelength);
272 12 SOAP::Trace::transport($http_request);
273 12 &{$self->{debug_logger}}($http_request->as_string);
274  
275 12 ▶ $self->SUPER::env_proxy if $ENV{'HTTP_proxy'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"HTTP_proxy"} 0 12 12
276  
277 # send and receive the stuff.
278 # TODO maybe eval this? what happens on connection close?
279 12 $self->http_response( $self->SUPER::request($http_request) );
280 12 SOAP::Trace::transport( $self->http_response );
281 12 &{$self->{debug_logger}}($self->http_response->as_string);
282  
283 # 100 OK, continue to read?
284 12 ▶ if ( (
Branch: 2 branches
BranchTrueFalseTotal
if ($self->http_response->code == 510 || $self->http_response->code == 501 and $method ne 'M-POST') { } 0 12 12
elsif ($self->http_response->code == 415 and $compressed) { } 0 12 12
Condition33%2/6
$self->http_response->code == 510 || $self->http_response->code == 501 and $method ne "M-POST"
!ll&&!rl&&r
1200
$self->http_response->code == 510 or $self->http_response->code == 501
l!l&&r!l&&!r
0012
MC/DC0%0/3
$self->http_response->code == 510 || $self->http_response->code == 501 and $method ne "M-POST"
$self->http_response->code == 510 $self->http_response->code == 501 $method ne "M-POST"
Truth table20%1/5
A or B and C
A= $self->http_response->code == 510B= $self->http_response->code == 501C= $method ne "M-POST"
ABCresult
00X0
1X00
0100
1X11
0111
285 $self->http_response->code == 510
286 || $self->http_response->code == 501
287 )
288 && $method ne 'M-POST'
289 ) {
290 0 $mpost{$endpoint} = 1;
291 }
292 ▶ elsif ( $self->http_response->code == 415 && $compressed ) {
Condition33%1/3
$self->http_response->code == 415 and $compressed
!ll&&!rl&&r
1200
MC/DC0%0/2
$self->http_response->code == 415 and $compressed
$self->http_response->code == 415 $compressed
Truth table33%1/3
A and B
A= $self->http_response->code == 415B= $compressed
ABresult
0X0
100
111
293  
294 # 415 Unsupported Media Type
295 0 $nocompress{$endpoint} = 1;
296 0 $envelope = Compress::Zlib::memGunzip($envelope);
297 0 $http_request->headers->remove_header('Content-Encoding');
298 0 redo COMPRESS; # try again without compression
299 }
300 else {
301 12 last;
302 }
303 }
304 }
305  
306 12 ▶ $redirect{$endpoint} = $self->http_response->request->url
Branch: 1 branch
BranchTrueFalseTotal
if $self->http_response->previous and $self->http_response->previous->is_redirect 1 11 12
Condition66%2/3
$self->http_response->previous and $self->http_response->previous->is_redirect
!ll&&!rl&&r
1101
MC/DC50%1/2
$self->http_response->previous and $self->http_response->previous->is_redirect
$self->http_response->previous $self->http_response->previous->is_redirect
Truth table66%2/3
A and B
A= $self->http_response->previousB= $self->http_response->previous->is_redirect
ABresult
0X0
100
111
307 if $self->http_response->previous
308 && $self->http_response->previous->is_redirect;
309  
310 12 $self->code( $self->http_response->code );
311 12 $self->message( $self->http_response->message );
312 12 $self->is_success( $self->http_response->is_success );
313 12 $self->status( $self->http_response->status_line );
314  
315 # Pull out any cookies from the response headers
316 $self->{'_cookie_jar'}->extract_cookies( $self->http_response )
317 12 ▶ if $self->{'_cookie_jar'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_cookie_jar"} 0 12 12
318  
319 my $content =
320 ( $self->http_response->content_encoding || '' ) =~
321 /\b$SOAP::Transport::HTTP::Client::COMPRESS\b/o
322 && $self->options->{is_compress}
323 12 ▶ ? Compress::Zlib::memGunzip( $self->http_response->content )
Branch: 2 branches
BranchTrueFalseTotal
($self->http_response->content_encoding || '') =~ /\b$SOAP::Transport::HTTP::Client::COMPRESS\b/o && $self->options->{'is_compress'} ? : 0 12 12
($self->http_response->content_encoding || '') =~ /\S/ ? : 0 12 12
Condition42%3/7
($self->http_response->content_encoding || "") =~ /\b$SOAP::Transport::HTTP::Client::COMPRESS\b/o and $self->options->{"is_compress"}
!ll&&!rl&&r
1200
$self->http_response->content_encoding || ''
l!l
012
$self->http_response->content_encoding || ''
l!l
012
MC/DC0%0/2
($self->http_response->content_encoding || "") =~ /\b$SOAP::Transport::HTTP::Client::COMPRESS\b/o and $self->options->{"is_compress"}
$self->http_response->content_encoding $self->options->{"is_compress"}
Truth table33%1/3
A and B
A= $self->http_response->content_encodingB= $self->options->{"is_compress"}
ABresult
0X0
100
111
324 : ( $self->http_response->content_encoding || '' ) =~ /\S/ ? die
325 0 "Can't understand returned Content-Encoding (@{[$self->http_response->content_encoding]})\n"
326 : $self->http_response->content;
327  
328 12 ▶ return $self->http_response->content_type =~ m!^multipart/!i
Branch: 1 branch
BranchTrueFalseTotal
$self->http_response->content_type =~ m[^multipart/]i ? : 0 12 12
329 ? join( "\n", $self->http_response->headers_as_string, $content )
330 : $content;
331 }
332  
333 # ======================================================================
334  
335 package SOAP::Transport::HTTP::Server;
336  
337 16 ▶use vars qw(@ISA $COMPRESS);
Subroutine BEGIN: called CC=1 SCAR=0.0
338 16 @ISA = qw(SOAP::Server);
339  
340 16 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
341  
342 16 $COMPRESS = 'deflate';
343  
344 1 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
345  
346 sub setDebugLogger {
347 5 ▶ my ($self,$logger) = @_;
Subroutine setDebugLogger: called CC=1 SCAR=0.0
348 5 $self->{debug_logger} = $logger;
349 }
350  
351 sub new {
352 23 ▶ require LWP::UserAgent;
Subroutine new: called CC=2 SCAR=8.1
353 23 my $self = shift;
354 23 ▶ return $self if ref $self; # we're already an object
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 18 5 23
355  
356 5 my $class = $self;
357 5 $self = $class->SUPER::new(@_);
358 $self->{'_on_action'} = sub {
359 1 ▶ ( my $action = shift || '' ) =~ s/^(\"?)(.*)\1$/$2/;
Subroutine __ANON__: called CC=7 SCAR=29.6
Condition50%1/2
shift() || ''
l!l
01
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
360 1 ▶ die
Branch: 1 branch
BranchTrueFalseTotal
if $action and $action ne join("#", @_) and $action ne join("/", @_) and substr($_[0], -1, 1) ne "/" || $action ne join("", @_) 0 1 1
Condition25%3/12
$action and $action ne join("#", @_) and $action ne join("/", @_) and substr($_[0], -1, 1) ne "/" || $action ne join("", @_)
!ll&&!rl&&r
100
$action and $action ne join("#", @_) and $action ne join("/", @_)
!ll&&!rl&&r
100
$action and $action ne join("#", @_)
!ll&&!rl&&r
100
substr($_[0], -1, 1) ne "/" or $action ne join("", @_)
l!l&&r!l&&!r
000
MC/DC0%0/5
$action and $action ne join("#", @_) and $action ne join("/", @_) and substr($_[0], -1, 1) ne "/" || $action ne join("", @_)
$action $action ne join("#", @_) $action ne join("/", @_) substr($_[0], -1, 1) ne "/" $action ne join("", @_)
Truth table16%1/6
A and B and C and D or E
A= $actionB= $action ne join("#", @_)C= $action ne join("/", @_)D= substr($_[0], -1, 1) ne "/"E= $action ne join("", @_)
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
361 0 "SOAPAction shall match 'uri#method' if present (got '$action', expected '@{[join('#', @_)]}'\n"
362 if $action
363 && $action ne join( '#', @_ )
364 && $action ne join( '/', @_ )
365 && ( substr( $_[0], -1, 1 ) ne '/'
366 || $action ne join( '', @_ ) );
367 5 };
368 5 SOAP::Trace::objects('()');
369  
370 5 $self->setDebugLogger(\&SOAP::Trace::debug);
371  
372 5 return $self;
373 }
374  
375 sub BEGIN {
376 16 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
377 16 ▶ for my $method (qw(request response)) {
Subroutine BEGIN: called CC=2 SCAR=6.9
378 32 my $field = '_' . $method;
379 *$method = sub {
380 27 ▶ my $self = shift->new;
Subroutine __ANON__: called CC=2 SCAR=6.9
381 @_
382 ? ( $self->{$field} = shift, return $self )
383 27 ▶ : return $self->{$field};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 6 21 27
384 32 };
385 }
386 }
387  
388 sub handle {
389 1 ▶ my $self = shift->new;
Subroutine handle: called CC=26 SCAR=48.5
390  
391 1 &{$self->{debug_logger}}($self->request->content);
392  
393 1 ▶ if ( $self->request->method eq 'POST' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->request->method eq 'POST') { } 1 0 1
elsif ($self->request->method eq 'M-POST') { } 0 0 0
394 1 ▶ $self->action( $self->request->header('SOAPAction') || undef );
Condition50%1/2
$self->request->header('SOAPAction') || undef
l!l
01
MC/DC0%0/1
$self->request->header('SOAPAction') || undef
$self->request->header('SOAPAction')
Truth table50%1/2
A
A= $self->request->header('SOAPAction')
Aresult
11
00
395 }
396 elsif ( $self->request->method eq 'M-POST' ) {
397 0 ▶ return $self->response(
Branch: 1 branch
BranchTrueFalseTotal
unless $self->request->header("Man") =~ /^"$SOAP::Constants::NS_ENV";\s*ns\s*=\s*(\d+)/ 0 0 0
398 HTTP::Response->new(
399 510, # NOT EXTENDED
400 "Expected Mandatory header with $SOAP::Constants::NS_ENV as unique URI"
401 ) )
402 if $self->request->header('Man') !~
403 /^"$SOAP::Constants::NS_ENV";\s*ns\s*=\s*(\d+)/;
404 0 ▶ $self->action( $self->request->header("$1-SOAPAction") || undef );
Condition0%0/2
$self->request->header("$1-SOAPAction") || undef
l!l
00
MC/DC0%0/1
$self->request->header("$1-SOAPAction") || undef
$self->request->header("$1-SOAPAction")
Truth table0%0/2
A
A= $self->request->header("$1-SOAPAction")
Aresult
11
00
405 }
406 else {
407 0 return $self->response(
408 HTTP::Response->new(405) ) # METHOD NOT ALLOWED
409 }
410  
411 1 ▶ my $compressed =
Condition50%1/2
$self->request->content_encoding || ''
l!l
01
MC/DC0%0/1
$self->request->content_encoding || ''
$self->request->content_encoding
Truth table50%1/2
A
A= $self->request->content_encoding
Aresult
11
00
412 ( $self->request->content_encoding || '' ) =~ /\b$COMPRESS\b/;
413 $self->options->{is_compress} ||=
414 1 ▶ $compressed && eval { require Compress::Zlib };
Condition33%2/6
$self->options->{"is_compress"} ||= $compressed && eval { do { require Compress::Zlib } }
l!l&&r!l&&!r
001
$compressed && eval { do { require Compress::Zlib } }
!ll&&!rl&&r
100
MC/DC0%0/3
$self->options->{"is_compress"} ||= $compressed && eval { do { require Compress::Zlib } }
$self->options->{"is_compress"} $compressed eval { do { require Compress::Zlib } }
Truth table0%0/4
A ||= B && C
A= $self->options->{"is_compress"}B= $compressedC= eval { do { require Compress::Zlib } }
ABCresult
1XX1
0111
00X0
0100
415  
416 # signal error if content-encoding is 'deflate', but we don't want it OR
417 # something else, so we don't understand it
418 return $self->response(
419 HTTP::Response->new(415) ) # UNSUPPORTED MEDIA TYPE
420 if $compressed && !$self->options->{is_compress}
421 1 ▶ || !$compressed
Branch: 1 branch
BranchTrueFalseTotal
if $compressed and not $self->options->{"is_compress"} or not $compressed and ($self->request->content_encoding || "") =~ /\S/ 0 1 1
Condition36%4/11
$compressed and not $self->options->{"is_compress"} or not $compressed and ($self->request->content_encoding || "") =~ /\S/
l!l&&r!l&&!r
001
$compressed and not $self->options->{"is_compress"}
!ll&&!rl&&r
100
not $compressed and ($self->request->content_encoding || "") =~ /\S/
!ll&&!rl&&r
010
$self->request->content_encoding || ''
l!l
01
MC/DC0%0/4
$compressed and not $self->options->{"is_compress"} or not $compressed and ($self->request->content_encoding || "") =~ /\S/
$compressed not $self->options->{"is_compress"} not $compressed $self->request->content_encoding
Truth table14%1/7
A and not(B) or not(C) and D
A= $compressedB= not $self->options->{"is_compress"}C= not $compressedD= $self->request->content_encoding
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
422 && ( $self->request->content_encoding || '' ) =~ /\S/;
423  
424 1 ▶ my $content_type = $self->request->content_type || '';
Condition50%1/2
$self->request->content_type || ''
l!l
01
MC/DC0%0/1
$self->request->content_type || ''
$self->request->content_type
Truth table50%1/2
A
A= $self->request->content_type
Aresult
11
00
425  
426 # in some environments (PerlEx?) content_type could be empty, so allow it also
427 # anyway it'll blow up inside ::Server::handle if something wrong with message
428 # TBD: but what to do with MIME encoded messages in THOSE environments?
429 1 ▶ return $self->make_fault( $SOAP::Constants::FAULT_CLIENT,
Branch: 1 branch
BranchTrueFalseTotal
if not $SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPE and $content_type and $content_type ne "application/soap+xml" and $content_type ne "text/xml" and $content_type ne "application/dime" and not $content_type =~ m[^multipart/] 0 1 1
Condition33%5/15
not $SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPE and $content_type and $content_type ne "application/soap+xml" and $content_type ne "text/xml" and $content_type ne "application/dime" and not $content_type =~ m[^multipart/]
!ll&&!rl&&r
100
not $SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPE and $content_type and $content_type ne "application/soap+xml" and $content_type ne "text/xml" and $content_type ne "application/dime"
!ll&&!rl&&r
100
not $SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPE and $content_type and $content_type ne "application/soap+xml" and $content_type ne "text/xml"
!ll&&!rl&&r
100
not $SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPE and $content_type and $content_type ne "application/soap+xml"
!ll&&!rl&&r
100
not $SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPE and $content_type
!ll&&!rl&&r
010
MC/DC0%0/6
not $SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPE and $content_type and $content_type ne "application/soap+xml" and $content_type ne "text/xml" and $content_type ne "application/dime" and not $content_type =~ m[^multipart/]
not $SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPE $content_type $content_type ne "application/soap+xml" $content_type ne "text/xml" $content_type ne "application/dime" not $content_type =~ m[^multipart/]
Truth table14%1/7
not(A) and B and C and D and E and not(F)
A= not $SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPEB= $content_typeC= $content_type ne "application/soap+xml"D= $content_type ne "text/xml"E= $content_type ne "application/dime"F= not $content_type =~ m[^multipart/]
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
430 "Content-Type must be 'text/xml,' 'multipart/*,' "
431 . "'application/soap+xml,' 'or 'application/dime' instead of '$content_type'"
432 )
433 if !$SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPE
434 && $content_type
435 && $content_type ne 'application/soap+xml'
436 && $content_type ne 'text/xml'
437 && $content_type ne 'application/dime'
438 && $content_type !~ m!^multipart/!;
439  
440 # TODO - Handle the Expect: 100-Continue HTTP/1.1 Header
441 1 ▶ if ( defined( $self->request->header("Expect") )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->request->header("Expect") and $self->request->header("Expect") eq "100-Continue") 0 1 1
Condition33%1/3
defined $self->request->header("Expect") and $self->request->header("Expect") eq "100-Continue"
!ll&&!rl&&r
100
MC/DC0%0/2
defined $self->request->header("Expect") and $self->request->header("Expect") eq "100-Continue"
defined $self->request->header("Expect") $self->request->header("Expect") eq "100-Continue"
Truth table33%1/3
A and B
A= defined $self->request->header("Expect")B= $self->request->header("Expect") eq "100-Continue"
ABresult
0X0
100
111
442 && ( $self->request->header("Expect") eq "100-Continue" ) ) {
443  
444 }
445  
446 # TODO - this should query SOAP::Packager to see what types it supports,
447 # I don't like how this is hardcoded here.
448 1 ▶ my $content =
Branch: 1 branch
BranchTrueFalseTotal
$compressed ? : 0 1 1
449 $compressed
450 ? Compress::Zlib::uncompress( $self->request->content )
451 : $self->request->content;
452  
453 1 ▶ my $response = $self->SUPER::handle(
Branch: 2 branches
BranchTrueFalseTotal
my $response = $self->SUPER::handle($self->request->content_type =~ m[^multipart/] ? join("\n", $self->request->headers_as_string, $content) : $content) or return 0 1 1
$self->request->content_type =~ m[^multipart/] ? : 0 1 1
454 $self->request->content_type =~ m!^multipart/!
455 ? join( "\n", $self->request->headers_as_string, $content )
456 : $content
457 ) or return;
458  
459 1 &{$self->{debug_logger}}($response);
460  
461 1 $self->make_response( $SOAP::Constants::HTTP_ON_SUCCESS_CODE, $response );
462 }
463  
464 sub make_fault {
465 2 ▶ my $self = shift;
Subroutine make_fault: called CC=1 SCAR=0.0
466 2 $self->make_response(
467 $SOAP::Constants::HTTP_ON_FAULT_CODE => $self->SUPER::make_fault(@_)
468 );
469 2 return;
470 }
471  
472 sub make_response {
473 3 ▶ my ( $self, $code, $response ) = @_;
Subroutine make_response: called CC=14 SCAR=35.2
474  
475 3 ▶ my $encoding = $1
Branch: 1 branch
BranchTrueFalseTotal
if $response =~ /^<\?xml(?: version="1.0"| encoding="([^\"]+)")+\?>/ 3 0 3
476 if $response =~ /^<\?xml(?: version="1.0"| encoding="([^\"]+)")+\?>/;
477  
478 3 ▶ $response =~ s!(\?>)!$1<?xml-stylesheet type="text/css"?>!
Branch: 1 branch
BranchTrueFalseTotal
if $self->request->content_type eq "multipart/form-data" 0 3 3
479 if $self->request->content_type eq 'multipart/form-data';
480  
481 $self->options->{is_compress} ||=
482 exists $self->options->{compress_threshold}
483 3 ▶ && eval { require Compress::Zlib };
Condition33%2/6
$self->options->{"is_compress"} ||= exists $self->options->{"compress_threshold"} && eval { do { require Compress::Zlib } }
l!l&&r!l&&!r
003
exists $self->options->{'compress_threshold'} && eval { do { require Compress::Zlib } }
!ll&&!rl&&r
300
MC/DC0%0/3
$self->options->{"is_compress"} ||= exists $self->options->{"compress_threshold"} && eval { do { require Compress::Zlib } }
$self->options->{"is_compress"} exists $self->options->{'compress_threshold'} eval { do { require Compress::Zlib } }
Truth table0%0/4
A ||= B && C
A= $self->options->{"is_compress"}B= exists $self->options->{'compress_threshold'}C= eval { do { require Compress::Zlib } }
ABCresult
1XX1
0111
00X0
0100
484  
485 my $compressed = $self->options->{is_compress}
486 && grep( /\b($COMPRESS|\*)\b/,
487 $self->request->header('Accept-Encoding') )
488 3 ▶ && ( $self->options->{compress_threshold} || 0 ) <
Condition25%2/8
$self->options->{'is_compress'} && grep(/\b($SOAP::Transport::HTTP::Server::COMPRESS|\*)\b/, $self->request->header('Accept-Encoding')) && ($self->options->{'compress_threshold'} || 0) < SOAP::Utils::bytelength($response)
!ll&&!rl&&r
300
$self->options->{"is_compress"} and grep /\b($SOAP::Transport::HTTP::Server::COMPRESS|\*)\b/, $self->request->header("Accept-Encoding")
!ll&&!rl&&r
300
$self->options->{'compress_threshold'} || 0
l!l
00
MC/DC0%0/3
$self->options->{'is_compress'} && grep(/\b($SOAP::Transport::HTTP::Server::COMPRESS|\*)\b/, $self->request->header('Accept-Encoding')) && ($self->options->{'compress_threshold'} || 0) < SOAP::Utils::bytelength($response)
$self->options->{"is_compress"} grep /\b($SOAP::Transport::HTTP::Server::COMPRESS|\*)\b/, $self->request->header("Accept-Encoding") $self->options->{'compress_threshold'}
Truth table25%1/4
A and B && C
A= $self->options->{"is_compress"}B= grep /\b($SOAP::Transport::HTTP::Server::COMPRESS|\*)\b/, $self->request->header("Accept-Encoding")C= $self->options->{'compress_threshold'}
ABCresult
0XX0
10X0
1100
1111
489 SOAP::Utils::bytelength $response;
490  
491 3 ▶ $response = Compress::Zlib::compress($response) if $compressed;
Branch: 1 branch
BranchTrueFalseTotal
if $compressed 0 3 3
492  
493 # this next line does not look like a good test to see if something is multipart
494 # perhaps a /content-type:.*multipart\//gi is a better regex?
495 3 my ($is_multipart) =
496 ( $response =~ /^content-type:.* boundary="([^\"]*)"/im );
497  
498 $self->response(
499 HTTP::Response->new(
500 $code => undef,
501 HTTP::Headers->new(
502 'SOAPServer' => $self->product_tokens,
503 $compressed ? ( 'Content-Encoding' => $COMPRESS ) : (),
504 'Content-Type' => join( '; ',
505 'text/xml',
506 !$SOAP::Constants::DO_NOT_USE_CHARSET
507 && $encoding ? 'charset=' . lc($encoding) : () ),
508 'Content-Length' => SOAP::Utils::bytelength $response
509 ),
510 ( $] > 5.007 )
511 3 ▶ ? do { require Encode; Encode::encode( $encoding, $response ) }
Branch: 3 branches
BranchTrueFalseTotal
$compressed ? : 0 3 3
!$SOAP::Constants::DO_NOT_USE_CHARSET && $encoding ? : 3 0 3
$] > 5.007 ? : 3 0 3
Condition33%1/3
not $SOAP::Constants::DO_NOT_USE_CHARSET and $encoding
!ll&&!rl&&r
003
MC/DC0%0/2
not $SOAP::Constants::DO_NOT_USE_CHARSET and $encoding
not $SOAP::Constants::DO_NOT_USE_CHARSET $encoding
Truth table33%1/3
not(A) and B
A= not $SOAP::Constants::DO_NOT_USE_CHARSETB= $encoding
ABresult
0X0
100
111
512 : $response,
513 ) );
514  
515 3 ▶ $self->response->headers->header( 'Content-Type' =>
Branch: 1 branch
BranchTrueFalseTotal
if $is_multipart 0 3 3
516 'Multipart/Related; type="text/xml"; start="<main_envelope>"; boundary="'
517 . $is_multipart
518 . '"' )
519 if $is_multipart;
520 }
521  
522 # ->VERSION leaks a scalar every call - no idea why.
523 sub product_tokens {
524 4 ▶ join '/', 'SOAP::Lite', 'Perl', $SOAP::Transport::HTTP::VERSION;
Subroutine product_tokens: called CC=1 SCAR=0.0
525 }
526  
527 # ======================================================================
528  
529 package SOAP::Transport::HTTP::CGI;
530  
531 16 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
532 16 @ISA = qw(SOAP::Transport::HTTP::Server);
533  
534 2 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
535  
536 sub new {
537 62 ▶ my $self = shift;
Subroutine new: called CC=3 SCAR=11.2
538 62 ▶ return $self if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 59 3 62
539  
540 3 ▶ my $class = ref($self) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
030
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
541 3 $self = $class->SUPER::new(@_);
542 3 SOAP::Trace::objects('()');
543  
544 3 return $self;
545 }
546  
547 sub make_response {
548 2 ▶ my $self = shift;
Subroutine make_response: called CC=1 SCAR=0.0
549 2 $self->SUPER::make_response(@_);
550 }
551  
552 sub handle {
553 1 ▶ my $self = shift->new;
Subroutine handle: called CC=23 SCAR=46.0
554  
555 1 ▶ my $length = $ENV{'CONTENT_LENGTH'} || 0;
Condition50%1/2
$ENV{'CONTENT_LENGTH'} || 0
l!l
10
MC/DC0%0/1
$ENV{'CONTENT_LENGTH'} || 0
$ENV{'CONTENT_LENGTH'}
Truth table50%1/2
A
A= $ENV{'CONTENT_LENGTH'}
Aresult
11
00
556  
557 # if the HTTP_TRANSFER_ENCODING env is defined, set $chunked if it's chunked*
558 # else to false
559 my $chunked = (defined $ENV{'HTTP_TRANSFER_ENCODING'}
560 1 ▶ && $ENV{'HTTP_TRANSFER_ENCODING'} =~ /^chunked.*$/) || 0;
Condition40%2/5
defined $ENV{'HTTP_TRANSFER_ENCODING'} && $ENV{'HTTP_TRANSFER_ENCODING'} =~ /^chunked.*$/ || 0
l!l
01
defined $ENV{"HTTP_TRANSFER_ENCODING"} and $ENV{"HTTP_TRANSFER_ENCODING"} =~ /^chunked.*$/
!ll&&!rl&&r
100
MC/DC0%0/2
defined $ENV{'HTTP_TRANSFER_ENCODING'} && $ENV{'HTTP_TRANSFER_ENCODING'} =~ /^chunked.*$/ || 0
defined $ENV{"HTTP_TRANSFER_ENCODING"} $ENV{"HTTP_TRANSFER_ENCODING"} =~ /^chunked.*$/
Truth table33%1/3
A and B
A= defined $ENV{"HTTP_TRANSFER_ENCODING"}B= $ENV{"HTTP_TRANSFER_ENCODING"} =~ /^chunked.*$/
ABresult
111
0X0
100
561  
562  
563 1 my $content = q{};
564  
565 1 ▶ if ($chunked) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chunked) 0 1 1
566 0 my $buffer;
567 0 binmode(STDIN);
568 0 ▶ while ( read( STDIN, my $buffer, 1024 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (read STDIN, my $buffer, 1024) 0 0 0
569 0 $content .= $buffer;
570 }
571 0 $length = length($content);
572 }
573  
574 1 ▶ if ( !$length ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $length) { } 0 1 1
elsif (defined $SOAP::Constants::MAX_CONTENT_SIZE and $length > $SOAP::Constants::MAX_CONTENT_SIZE) { } 0 1 1
575 0 $self->response( HTTP::Response->new(411) ) # LENGTH REQUIRED
576 }
577 ▶ elsif ( defined $SOAP::Constants::MAX_CONTENT_SIZE
Condition33%1/3
defined $SOAP::Constants::MAX_CONTENT_SIZE and $length > $SOAP::Constants::MAX_CONTENT_SIZE
!ll&&!rl&&r
100
MC/DC0%0/2
defined $SOAP::Constants::MAX_CONTENT_SIZE and $length > $SOAP::Constants::MAX_CONTENT_SIZE
defined $SOAP::Constants::MAX_CONTENT_SIZE $length > $SOAP::Constants::MAX_CONTENT_SIZE
Truth table33%1/3
A and B
A= defined $SOAP::Constants::MAX_CONTENT_SIZEB= $length > $SOAP::Constants::MAX_CONTENT_SIZE
ABresult
0X0
100
111
578 && $length > $SOAP::Constants::MAX_CONTENT_SIZE ) {
579 0 $self->response( HTTP::Response->new(413) ) # REQUEST ENTITY TOO LARGE
580 }
581 else {
582 1 ▶ if ( exists $ENV{EXPECT} && $ENV{EXPECT} =~ /\b100-Continue\b/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{"EXPECT"} and $ENV{"EXPECT"} =~ /\b100-Continue\b/i) 0 1 1
Condition33%1/3
exists $ENV{"EXPECT"} and $ENV{"EXPECT"} =~ /\b100-Continue\b/i
!ll&&!rl&&r
100
MC/DC0%0/2
exists $ENV{"EXPECT"} and $ENV{"EXPECT"} =~ /\b100-Continue\b/i
exists $ENV{"EXPECT"} $ENV{"EXPECT"} =~ /\b100-Continue\b/i
Truth table33%1/3
A and B
A= exists $ENV{"EXPECT"}B= $ENV{"EXPECT"} =~ /\b100-Continue\b/i
ABresult
0X0
100
111
583 0 print "HTTP/1.1 100 Continue\r\n\r\n";
584 }
585  
586 #my $content = q{};
587 1 ▶ if ( !$chunked ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chunked) 1 0 1
588 1 my $buffer;
589 1 binmode(STDIN);
590 1 ▶ if ( defined $ENV{'MOD_PERL'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{'MOD_PERL'}) { } 0 1 1
591 0 ▶ while ( read( STDIN, $buffer, $length ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (read STDIN, $buffer, $length) 0 0 0
592 0 $content .= $buffer;
593 0 ▶ last if ( length($content) >= $length );
Branch: 1 branch
BranchTrueFalseTotal
if length $content >= $length 0 0 0
594 }
595 } else {
596 1 ▶ while ( sysread( STDIN, $buffer, $length ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (sysread STDIN, $buffer, $length) 1 0 1
597 1 $content .= $buffer;
598 1 ▶ last if ( length($content) >= $length );
Branch: 1 branch
BranchTrueFalseTotal
if length $content >= $length 1 0 1
599 }
600 }
601 }
602  
603 $self->request(
604 HTTP::Request->new(
605 $ENV{'REQUEST_METHOD'} || '' => $ENV{'SCRIPT_NAME'},
606 HTTP::Headers->new(
607 1 ▶ map { (
Condition50%1/2
$ENV{'REQUEST_METHOD'} || ''
l!l
10
MC/DC0%0/1
$ENV{'REQUEST_METHOD'} || ''
$ENV{'REQUEST_METHOD'}
Truth table50%1/2
A
A= $ENV{'REQUEST_METHOD'}
Aresult
11
00
608 /^HTTP_(.+)/i
609 ? ( $1 =~ m/SOAPACTION/ )
610 ? ('SOAPAction')
611 : ($1)
612 : $_
613 32 ▶ ) => $ENV{$_}
Branch: 2 branches
BranchTrueFalseTotal
/^HTTP_(.+)/i ? : 0 32 32
$1 =~ /SOAPACTION/ ? : 0 0 0
614 } keys %ENV
615 ),
616 $content,
617 ) );
618 1 $self->SUPER::handle;
619 }
620  
621 # imitate nph- cgi for IIS (pointed by Murray Nesbitt)
622 my $status =
623 defined( $ENV{'SERVER_SOFTWARE'} )
624 && $ENV{'SERVER_SOFTWARE'} =~ /IIS/
625 1 ▶ ? $ENV{SERVER_PROTOCOL} || 'HTTP/1.0'
Branch: 1 branch
BranchTrueFalseTotal
defined $ENV{'SERVER_SOFTWARE'} && $ENV{'SERVER_SOFTWARE'} =~ /IIS/ ? : 0 1 1
Condition20%1/5
defined $ENV{"SERVER_SOFTWARE"} and $ENV{"SERVER_SOFTWARE"} =~ /IIS/
!ll&&!rl&&r
100
$ENV{"SERVER_PROTOCOL"} or "HTTP/1.0"
l!l
00
MC/DC0%0/2
defined $ENV{"SERVER_SOFTWARE"} and $ENV{"SERVER_SOFTWARE"} =~ /IIS/
defined $ENV{"SERVER_SOFTWARE"} $ENV{"SERVER_SOFTWARE"} =~ /IIS/
MC/DC0%0/1
$ENV{"SERVER_PROTOCOL"} or "HTTP/1.0"
$ENV{"SERVER_PROTOCOL"}
Truth table33%1/3
A and B
A= defined $ENV{"SERVER_SOFTWARE"}B= $ENV{"SERVER_SOFTWARE"} =~ /IIS/
ABresult
0X0
100
111
Truth table0%0/2
A
A= $ENV{"SERVER_PROTOCOL"}
Aresult
11
00
626 : 'Status:';
627 1 my $code = $self->response->code;
628  
629 1 binmode(STDOUT);
630  
631 1 print STDOUT "$status $code ", HTTP::Status::status_message($code),
632 "\015\012", $self->response->headers_as_string("\015\012"), "\015\012",
633 $self->response->content;
634 }
635  
636 # ======================================================================
637  
638 package SOAP::Transport::HTTP::Daemon;
639  
640 16 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
641 16 ▶use vars qw($AUTOLOAD @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
642 16 @ISA = qw(SOAP::Transport::HTTP::Server);
643  
644 1 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
645  
646 #sub new { require HTTP::Daemon;
647 sub new {
648 17 ▶ my $self = shift;
Subroutine new: called CC=11 SCAR=30.2
649 17 ▶ return $self if ( ref $self );
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 16 1 17
650  
651 1 my $class = $self;
652  
653 1 my ( @params, @methods );
654 1 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 1 1
655 0 ▶ $class->can( $_[0] )
Branch: 1 branch
BranchTrueFalseTotal
$class->can($_[0]) ? : 0 0 0
656 ? push( @methods, shift() => shift )
657 : push( @params, shift );
658 }
659 1 $self = $class->SUPER::new;
660  
661 # Added in 0.65 - Thanks to Nils Sowen
662 # use SSL if there is any parameter with SSL_* in the name
663 1 ▶ $self->SSL(1) if !$self->SSL && grep /^SSL_/, @params;
Branch: 1 branch
BranchTrueFalseTotal
if not $self->SSL and grep /^SSL_/, @params 0 1 1
Condition33%1/3
not $self->SSL and grep /^SSL_/, @params
!ll&&!rl&&r
010
MC/DC0%0/2
not $self->SSL and grep /^SSL_/, @params
not $self->SSL grep /^SSL_/, @params
Truth table33%1/3
not(A) and B
A= not $self->SSLB= grep /^SSL_/, @params
ABresult
0X0
100
111
664 1 my $http_daemon = $self->http_daemon_class;
665 1 ▶ eval "require $http_daemon"
Branch: 1 branch
BranchTrueFalseTotal
unless $http_daemon->can("new") 1 0 1
Condition33%2/6
$http_daemon->can('new') || (eval "require $http_daemon" || Carp::croak($@))
l!l&&r!l&&!r
010
eval "require $http_daemon" or Carp::croak($@)
l!l&&r!l&&!r
100
MC/DC0%0/3
$http_daemon->can('new') || (eval "require $http_daemon" || Carp::croak($@))
$http_daemon->can('new') eval "require $http_daemon" Carp::croak($@)
Truth table0%0/4
A || B or C
A= $http_daemon->can('new')B= eval "require $http_daemon"C= Carp::croak($@)
ABCresult
1XX1
01X1
0011
0000
666 or Carp::croak $@
667 unless $http_daemon->can('new');
668  
669 1 ▶ $self->{_daemon} = $http_daemon->new(@params)
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_daemon"} = $http_daemon->new(@params) or Carp::croak("Can't create daemon: $!") 0 1 1
670 or Carp::croak "Can't create daemon: $!";
671  
672 # End SSL patch
673  
674 1 $self->myuri( URI->new( $self->url )->canonical->as_string );
675  
676 1 ▶ while (@methods) {
Branch: 1 branch
BranchTrueFalseTotal
if (@methods) 0 1 1
677 0 my ( $method, $params ) = splice( @methods, 0, 2 );
678 0 ▶ $self->$method(
Branch: 1 branch
BranchTrueFalseTotal
ref $params eq 'ARRAY' ? : 0 0 0
679 ref $params eq 'ARRAY'
680 ? @$params
681 : $params
682 );
683 }
684 1 SOAP::Trace::objects('()');
685  
686 1 return $self;
687 }
688  
689 sub SSL {
690 8 ▶ my $self = shift->new;
Subroutine SSL: called CC=2 SCAR=6.9
691 8 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 6 8
692 2 $self->{_SSL} = shift;
693 2 return $self;
694 }
695 6 return $self->{_SSL};
696 }
697  
698 3 ▶sub http_daemon_class { shift->SSL ? 'HTTP::Daemon::SSL' : 'HTTP::Daemon' }
Subroutine http_daemon_class: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
(shift())->SSL ? : 1 2 3
699  
700 sub AUTOLOAD {
701 1 ▶ my $method = substr( $AUTOLOAD, rindex( $AUTOLOAD, '::' ) + 2 );
Subroutine AUTOLOAD: called CC=2 SCAR=7.0
702 1 ▶ return if $method eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "DESTROY" 0 1 1
703  
704 16 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
705 1 ▶ *$AUTOLOAD = sub { shift->{_daemon}->$method(@_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
706 1 goto &$AUTOLOAD;
707 }
708  
709 sub handle {
710 0 ▶ my $self = shift->new;
Subroutine handle: not called CC=6 SCAR=37.4
711 0 ▶ while ( my $c = $self->accept ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $c = $self->accept) 0 0 0
712 0 ▶ while ( my $r = $c->get_request ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $r = $c->get_request) 0 0 0
713 0 $self->request($r);
714 0 $self->SUPER::handle;
715 0 eval {
716 0 ▶ local $SIG{PIPE} = sub {die "SIGPIPE"};
Subroutine __ANON__: not called CC=1 SCAR=6.9
717 0 $c->send_response( $self->response );
718 };
719 0 ▶ if ($@ && $@ !~ /^SIGPIPE/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ and not $@ =~ /^SIGPIPE/) 0 0 0
Condition0%0/3
$@ and not $@ =~ /^SIGPIPE/
!ll&&!rl&&r
000
MC/DC0%0/2
$@ and not $@ =~ /^SIGPIPE/
$@ not $@ =~ /^SIGPIPE/
Truth table0%0/3
A and not(B)
A= $@B= not $@ =~ /^SIGPIPE/
ABresult
0X0
100
111
720 0 die $@;
721 }
722 }
723  
724 # replaced ->close, thanks to Sean Meisner <Sean.Meisner@VerizonWireless.com>
725 # shutdown() doesn't work on AIX. close() is used in this case. Thanks to Jos Clijmans <jos.clijmans@recyfin.be>
726 0 ▶ $c->can('shutdown')
Branch: 1 branch
BranchTrueFalseTotal
$c->can('shutdown') ? : 0 0 0
727 ? $c->shutdown(2)
728 : $c->close();
729 0 $c->close;
730 }
731 }
732  
733 # ======================================================================
734  
735 package SOAP::Transport::HTTP::Apache;
736  
737 16 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
738 16 @ISA = qw(SOAP::Transport::HTTP::Server);
739  
740 0 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: not called CC=1 SCAR=6.9
741  
742 sub new {
743 0 ▶ my $self = shift;
Subroutine new: not called CC=8 SCAR=42.8
744 0 ▶ unless ( ref $self ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 0 0 0
745 0 ▶ my $class = ref($self) || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
746 0 $self = $class->SUPER::new(@_);
747 0 SOAP::Trace::objects('()');
748 }
749  
750 # Added this code thanks to JT Justman
751 # This code improves and provides more robust support for
752 # multiple versions of Apache and mod_perl
753  
754 # mod_perl 2.0
755 0 ▶ if ( defined $ENV{MOD_PERL_API_VERSION}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{'MOD_PERL_API_VERSION'} and $ENV{'MOD_PERL_API_VERSION'} >= 2) { } 0 0 0
Condition0%0/3
defined $ENV{"MOD_PERL_API_VERSION"} and $ENV{"MOD_PERL_API_VERSION"} >= 2
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ENV{"MOD_PERL_API_VERSION"} and $ENV{"MOD_PERL_API_VERSION"} >= 2
defined $ENV{"MOD_PERL_API_VERSION"} $ENV{"MOD_PERL_API_VERSION"} >= 2
Truth table0%0/3
A and B
A= defined $ENV{"MOD_PERL_API_VERSION"}B= $ENV{"MOD_PERL_API_VERSION"} >= 2
ABresult
0X0
100
111
756 && $ENV{MOD_PERL_API_VERSION} >= 2 ) {
757 0 require Apache2::RequestRec;
758 0 require Apache2::RequestIO;
759 0 require Apache2::Const;
760 0 require Apache2::RequestUtil;
761 0 require APR::Table;
762 0 Apache2::Const->import( -compile => 'OK' );
763 0 Apache2::Const->import( -compile => 'HTTP_BAD_REQUEST' );
764 0 $self->{'MOD_PERL_VERSION'} = 2;
765 0 $self->{OK} = &Apache2::Const::OK;
766 }
767 else { # mod_perl 1.xx
768 0 ▶ die "Could not find or load mod_perl"
Branch: 1 branch
BranchTrueFalseTotal
unless eval "require mod_perl" 0 0 0
769 unless ( eval "require mod_perl" );
770 0 ▶ die "Could not detect your version of mod_perl"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mod_perl::VERSION 0 0 0
771 if ( !defined($mod_perl::VERSION) );
772 0 ▶ if ( $mod_perl::VERSION < 1.99 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mod_perl::VERSION < 1.99) { } 0 0 0
773 0 require Apache;
774 0 require Apache::Constants;
775 0 Apache::Constants->import('OK');
776 0 Apache::Constants->import('HTTP_BAD_REQUEST');
777 0 $self->{'MOD_PERL_VERSION'} = 1;
778 0 $self->{OK} = &Apache::Constants::OK;
779 }
780 else {
781 0 require Apache::RequestRec;
782 0 require Apache::RequestIO;
783 0 require Apache::Const;
784 0 Apache::Const->import( -compile => 'OK' );
785 0 Apache::Const->import( -compile => 'HTTP_BAD_REQUEST' );
786 0 $self->{'MOD_PERL_VERSION'} = 1.99;
787 0 $self->{OK} = &Apache::OK;
788 }
789 }
790  
791 0 return $self;
792 }
793  
794 sub handler {
795 0 ▶ my $self = shift->new;
Subroutine handler: not called CC=10 SCAR=47.0
796 0 my $r = shift;
797  
798 # Begin patch from JT Justman
799 0 ▶ if ( !$r ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($r) 0 0 0
800 0 ▶ if ( $self->{'MOD_PERL_VERSION'} < 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'MOD_PERL_VERSION'} < 2) { } 0 0 0
801 0 $r = Apache->request();
802 }
803 else {
804 0 $r = Apache2::RequestUtil->request();
805 }
806 }
807  
808 0 my $cont_len;
809 0 ▶ if ( $self->{'MOD_PERL_VERSION'} < 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'MOD_PERL_VERSION'} < 2) { } 0 0 0
810 0 $cont_len = $r->header_in('Content-length');
811 }
812 else {
813 0 $cont_len = $r->headers_in->get('Content-length');
814 }
815  
816 # End patch from JT Justman
817  
818 0 my $content = "";
819 0 ▶ if ( $cont_len > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cont_len > 0) { } 0 0 0
820 0 my $buf;
821  
822 # attempt to slurp in the content at once...
823 0 ▶ $content .= $buf while ( $r->read( $buf, $cont_len ) > 0 );
Branch: 1 branch
BranchTrueFalseTotal
$r->read($buf, $cont_len) > 0 and do { $content .= $buf } 0 0 0
824 }
825 else {
826  
827 # throw appropriate error for mod_perl 2
828 return Apache2::Const::HTTP_BAD_REQUEST()
829 0 ▶ if ( $self->{'MOD_PERL_VERSION'} >= 2 );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"MOD_PERL_VERSION"} >= 2 0 0 0
830 0 return Apache::Constants::BAD_REQUEST();
831 }
832  
833 0 my %headers;
834 0 ▶ if ( $self->{'MOD_PERL_VERSION'} < 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'MOD_PERL_VERSION'} < 2) { } 0 0 0
835 0 %headers = $r->headers_in; # Apache::Table structure
836 } else {
837 0 %headers = %{ $r->headers_in }; # Apache2::RequestRec structure
838 }
839  
840 0 $self->request(
841 HTTP::Request->new(
842 $r->method() => $r->uri,
843 HTTP::Headers->new( %headers ),
844 $content
845 ) );
846 0 $self->SUPER::handle;
847  
848 # we will specify status manually for Apache, because
849 # if we do it as it has to be done, returning SERVER_ERROR,
850 # Apache will modify our content_type to 'text/html; ....'
851 # which is not what we want.
852 # will emulate normal response, but with custom status code
853 # which could also be 500.
854 0 ▶ if ($self->{'MOD_PERL_VERSION'} < 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'MOD_PERL_VERSION'} < 2) { } 0 0 0
855 0 $r->status( $self->response->code );
856 }
857 else {
858 0 $r->status_line($self->response->code);
859 }
860  
861 # Begin JT Justman patch
862 0 ▶ if ( $self->{'MOD_PERL_VERSION'} > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'MOD_PERL_VERSION'} > 1) { } 0 0 0
863 0 ▶ $self->response->headers->scan(sub { $r->headers_out->add(@_) });
Subroutine __ANON__: not called CC=1 SCAR=6.9
864 0 $r->content_type( join '; ', $self->response->content_type );
865 }
866 else {
867 0 ▶ $self->response->headers->scan( sub { $r->header_out(@_) } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
868 0 $r->send_http_header( join '; ', $self->response->content_type );
869 }
870  
871 0 $r->print( $self->response->content );
872 0 return $self->{OK};
873  
874 # End JT Justman patch
875 }
876  
877 sub configure {
878 0 ▶ my $self = shift->new;
Subroutine configure: not called CC=5 SCAR=34.0
879 0 my $config = shift->dir_config;
880 0 for (%$config) {
881 $config->{$_} =~ /=>/
882 ? $self->$_( {split /\s*(?:=>|,)\s*/, $config->{$_}} )
883 : ref $self->$_() ? () # hm, nothing can be done here
884 0 ▶ : $self->$_( split /\s+|\s*,\s*/, $config->{$_} )
Branch: 3 branches
BranchTrueFalseTotal
if $self->can($_) 0 0 0
$config->{$_} =~ /=>/ ? : 0 0 0
ref $self->$_ ? : 0 0 0
885 if $self->can($_);
886 }
887 0 return $self;
888 }
889  
890 {
891  
892 # just create alias
893 16 sub handle;
894 16 *handle = \&handler
895 }
896  
897 # ======================================================================
898 #
899 # Copyright (C) 2001 Single Source oy (marko.asplund@kronodoc.fi)
900 # a FastCGI transport class for SOAP::Lite.
901 # Updated formatting and removed dead code in new() in 2008
902 # by Martin Kutter
903 #
904 # ======================================================================
905  
906 package SOAP::Transport::HTTP::FCGI;
907  
908 16 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
909 16 @ISA = qw(SOAP::Transport::HTTP::CGI);
910  
911 1 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
912  
913 sub new {
914  
915 7 ▶ require FCGI;
Subroutine new: called CC=2 SCAR=6.9
916 7 Exporter::require_version( 'FCGI' => 0.47 )
917 ; # requires thread-safe interface
918  
919 7 my $class = shift;
920 7 ▶ return $class if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 6 1 7
921  
922 1 my $self = $class->SUPER::new(@_);
923 1 $self->{_fcgirq} = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR );
924 1 SOAP::Trace::objects('()');
925  
926 1 return $self;
927 }
928  
929 sub handle {
930 0 ▶ my $self = shift->new;
Subroutine handle: not called CC=2 SCAR=17.9
931  
932 0 my ( $r1, $r2 );
933 0 my $fcgirq = $self->{_fcgirq};
934  
935 0 ▶ while ( ( $r1 = $fcgirq->Accept() ) >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($r1 = $fcgirq->Accept) >= 0) 0 0 0
936 0 $r2 = $self->SUPER::handle;
937 }
938  
939 0 return undef;
940 }
941  
942 # ======================================================================
943  
944 16 1;
« lib/SOAP/Test.pm ↑ Summary lib/SOAP/Transport/POP3.pm »