| 1 | # Copyrights 2007-2022 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.03. | ||||||||||||||||||||||||||||
| 5 | # This code is part of distribution XML-Compile-SOAP. Meta-POD processed | ||||||||||||||||||||||||||||
| 6 | # with OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | package XML::Compile::SOAP::Trace; | ||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 7 | $VERSION = '3.28'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 7 | ▶ | use Log::Report 'xml-compile-soap', syntax => 'REPORT'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | # no syntax SHORT, because we have own error() | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 7 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 7 | my @xml_parse_opts = (load_ext_dtd => 0, recover => 1, no_network => 1); | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | sub new($) | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | { my ($class, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 0 | bless $data, $class; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub start() {shift->{start}} | ||||||||||||||||||||||||||
|
Subroutine
start: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub date() {scalar localtime shift->start} | ||||||||||||||||||||||||||
|
Subroutine
date: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub error(;$) | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
error: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | my $errors = $self->{errors} ||= []; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"errors"} ||= []
MC/DC0%0/1
$self->{"errors"} ||= []
$self->{"errors"}
Truth table0%0/2
A
A= $self->{"errors"}
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | foreach my $err (@_) | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | { $err = __$err unless ref $err; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $err = Log::Report::Exception->new(reason => 'ERROR', message => $err) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | unless $err->isa('Log::Report::Exception'); | ||||||||||||||||||||||||||||
| 45 | 0 | push @$errors, $err; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | wantarray ? @$errors : $errors->[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub errors() { @{shift->{errors} || []} } | ||||||||||||||||||||||||||
|
Subroutine
errors: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/2
+(shift())->{'errors'} || []
MC/DC0%0/1
+(shift())->{'errors'} || []
+(shift())->{'errors'}
Truth table0%0/2
A
A= +(shift())->{'errors'}
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | sub elapse($) | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | { my ($self, $kind) = @_; | ||||||||||||||||||||||||||
|
Subroutine
elapse: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | defined $kind ? $self->{$kind.'_elapse'} : $self->{elapse}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub request() {shift->{http_request}} | ||||||||||||||||||||||||||
|
Subroutine
request: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub response() {shift->{http_response}} | ||||||||||||||||||||||||||
|
Subroutine
response: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub responseDOM() {shift->{response_dom}} | ||||||||||||||||||||||||||
|
Subroutine
responseDOM: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | sub printTimings(;$) | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | { my ($self, $fh) = @_; | ||||||||||||||||||||||||||
|
Subroutine
printTimings: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my $oldfh = $fh ? (select $fh) : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 0 | print "Call initiated at: ",$self->date, "\n"; | |||||||||||||||||||||||||||
| 74 | 0 | print "SOAP call timing:\n"; | |||||||||||||||||||||||||||
| 75 | 0 | printf " encoding: %7.2f ms\n", $self->elapse('encode') *1000; | |||||||||||||||||||||||||||
| 76 | 0 | printf " stringify: %7.2f ms\n", $self->elapse('stringify') *1000; | |||||||||||||||||||||||||||
| 77 | 0 | printf " connection: %7.2f ms\n", $self->elapse('connect') *1000; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | my $dp = $self->elapse('parse'); | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | if(defined $dp) {printf " parsing: %7.2f ms\n", $dp *1000 } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | else {printf " parsing: - (no xml to parse)\n" } | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | my $dt = $self->elapse('decode'); | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | if(defined $dt) {printf " decoding: %7.2f ms\n", $dt *1000 } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | else {print " decoding: - (no xml to convert)\n"} | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | my $el = $self->elapse; | |||||||||||||||||||||||||||
| 88 | 0 | ▶ | printf " total time: %7.2f ms = %.3f seconds\n\n", $el*1000, $el | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | if defined $el; | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | select $oldfh if $oldfh; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | sub printRequest(;$%) | ||||||||||||||||||||||||||||
| 96 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
printRequest: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | my $request = $self->request or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | my $fh = @_%2 ? shift : *STDOUT; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | my $format = $args{pretty_print} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'pretty_print'} || 0
MC/DC0%0/1
$args{'pretty_print'} || 0
$args{'pretty_print'}
Truth table0%0/2
A
A= $args{'pretty_print'}
| |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if($format && $request->content_type =~ m/xml/i) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$format and $request->content_type =~ /xml/i
MC/DC0%0/2
$format and $request->content_type =~ /xml/i
$format
$request->content_type =~ /xml/i
Truth table0%0/3
A and B
A= $formatB= $request->content_type =~ /xml/i
| |||||||||||||||||||||||||||||
| 104 | 0 | { $fh->print("\n", $request->headers->as_string, "\n"); | |||||||||||||||||||||||||||
| 105 | 0 | XML::LibXML | |||||||||||||||||||||||||||
| 106 | ->load_xml(string => $request->content, @xml_parse_opts) | ||||||||||||||||||||||||||||
| 107 | ->toFH($fh, $format); | ||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | else | ||||||||||||||||||||||||||||
| 110 | 0 | { my $req = $request->as_string; | |||||||||||||||||||||||||||
| 111 | 0 | $req =~ s/^/ /gm; | |||||||||||||||||||||||||||
| 112 | 0 | $fh->print("Request:\n$req\n"); | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | sub printResponse(;$%) | ||||||||||||||||||||||||||||
| 118 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
printResponse: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | my $resp = $self->response or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my $fh = @_%2 ? shift : *STDOUT; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | my $format = $args{pretty_print} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'pretty_print'} || 0
MC/DC0%0/1
$args{'pretty_print'} || 0
$args{'pretty_print'}
Truth table0%0/2
A
A= $args{'pretty_print'}
| |||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if($format && $resp->content_type =~ m/xml/i) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$format and $resp->content_type =~ /xml/i
MC/DC0%0/2
$format and $resp->content_type =~ /xml/i
$format
$resp->content_type =~ /xml/i
Truth table0%0/3
A and B
A= $formatB= $resp->content_type =~ /xml/i
| |||||||||||||||||||||||||||||
| 126 | 0 | { $fh->print("\n", $resp->headers->as_string, "\n"); | |||||||||||||||||||||||||||
| 127 | 0 | ▶ | XML::LibXML->load_xml | ||||||||||||||||||||||||||
|
Condition0%0/3
$resp->decoded_content || $resp->content
MC/DC0%0/2
$resp->decoded_content || $resp->content
$resp->decoded_content
$resp->content
Truth table0%0/3
A || B
A= $resp->decoded_contentB= $resp->content
| |||||||||||||||||||||||||||||
| 128 | ( string => ($resp->decoded_content || $resp->content) | ||||||||||||||||||||||||||||
| 129 | , @xml_parse_opts | ||||||||||||||||||||||||||||
| 130 | )->toFH($fh, $format); | ||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | else | ||||||||||||||||||||||||||||
| 133 | 0 | { my $resp = $resp->as_string; | |||||||||||||||||||||||||||
| 134 | 0 | $resp =~ s/^/ /gm; | |||||||||||||||||||||||||||
| 135 | 0 | $fh->print("Response:\n$resp\n"); | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | sub printErrors(;$) | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | { my ($self, $fh) = @_; | ||||||||||||||||||||||||||
|
Subroutine
printErrors: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $fh ||= *STDERR; | ||||||||||||||||||||||||||
|
Condition0%0/3
$fh ||= *STDERR
MC/DC0%0/2
$fh ||= *STDERR
$fh
*STDERR
Truth table0%0/3
A ||= B
A= $fhB= *STDERR
| |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 0 | print $fh $_->toString for $self->errors; | |||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if(my $d = $self->{decode_errors}) # Log::Report::Dispatcher::Try object | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | { print $fh "Errors while decoding:\n"; | |||||||||||||||||||||||||||
| 148 | 0 | foreach my $e ($d->exceptions) | |||||||||||||||||||||||||||
| 149 | 0 | { print $fh " ", $e->toString; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 7 | 1; | |||||||||||||||||||||||||||