blib/lib/SOAP/WSDL/Transport/HTTP.pm

filter: Statementstmt 100% 42 / 42 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 98.3% 59 / 60 CC 5 SCAR 7.3
CC
5
Cov
100%
send_receive
4.0
__ANON__
2.0
BEGIN
1.0
CRAP 2.1
« blib/lib/SOAP/WSDL/XSD/Schema.pm ↑ Summary blib/lib/SOAP/WSDL/XSD/Typelib/Builtin/anySimpleType.pm »
1 package SOAP::WSDL::Transport::HTTP;
2 2 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use base qw(LWP::UserAgent);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use version; our $VERSION = qv('3.00.0_2');
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # create methods normally inherited from SOAP::Client
8 SUBFACTORY: {
9 2 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 foreach my $method ( qw(code message status is_success) ) {
11 8 *{ $method } = sub {
12 23 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
13 23 ▶ return $self->{ $method } if not @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 3 20 23
14 20 return $self->{ $method } = shift;
15 8 };
16 }
17 }
18  
19 sub _agent {
20 3 ▶ return qq[SOAP::WSDL $VERSION];
Subroutine _agent: called CC=1 SCAR=0.0
21 }
22  
23 sub send_receive {
24 4 ▶ my ($self, %parameters) = @_;
Subroutine send_receive: called CC=4 SCAR=13.9
Pod undocumented
25 my ($envelope, $soap_action, $endpoint, $encoding, $content_type) =
26 4 @parameters{qw(envelope action endpoint encoding content_type)};
27  
28 4 ▶ $encoding = defined($encoding)
Branch: 1 branch
BranchTrueFalseTotal
defined $encoding ? : 2 2 4
29 ? lc($encoding)
30 : 'utf-8';
31  
32 4 ▶ $content_type = "text/xml; charset=$encoding"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $content_type 3 1 4
33 if not defined($content_type);
34 # what's this all about?
35 # unfortunately combination of LWP and Perl 5.6.1 and later has bug
36 # in sending multibyte characters. LWP uses length() to calculate
37 # content-length header and starting 5.6.1 length() calculates chars
38 # instead of bytes. 'use bytes' in THIS file doesn't work, because
39 # it's lexically scoped. Unfortunately, content-length we calculate
40 # here doesn't work either, because LWP overwrites it with
41 # content-length it calculates (which is wrong) AND uses length()
42 # during syswrite/sysread, so we are in a bad shape anyway.
43 #
44 # what to do? we calculate proper content-length (using
45 # bytelength() function from SOAP::Utils) and then drop utf8 mark
46 # from string (doing pack with 'C0A*' modifier) if length and
47 # bytelength are not the same
48  
49 # use bytes is lexically scoped
50 2 ▶ my $bytelength = do { use bytes; length $envelope };
Subroutine BEGIN: called CC=1 SCAR=0.0
51 4 ▶ $envelope = pack('C0A*', $envelope)
Branch: 1 branch
BranchTrueFalseTotal
if length $envelope != $bytelength 2 2 4
52 if length($envelope) != $bytelength;
53  
54 4 my $request = HTTP::Request->new( 'POST',
55 $endpoint,
56 [ 'Content-Type', "$content_type",
57 'Content-Length', $bytelength,
58 'SOAPAction', $soap_action,
59 ],
60 $envelope );
61  
62 4 my $response = $self->request( $request );
63  
64 4 $self->code( $response->code);
65 4 $self->message( $response->message);
66 4 $self->is_success($response->is_success);
67 4 $self->status($response->status_line);
68  
69 4 return $response->content();
70 }
71  
72 2 1;
73  
74 =pod
75  
76 =head1 NAME
77  
78 SOAP::WSDL::Transport::HTTP - Fallback http(s) transport class
79  
80 =head1 DESCRIPTION
81  
82 Provides a thin transport class used by SOAP::WSDL::Transport when
83 SOAP::Lite is not available.
84  
85 =head1 LICENSE AND COPYRIGHT
86  
87 Copyright (c) 2007 Martin Kutter. All rights reserved.
88  
89 This file is part of SOAP-WSDL. You may distribute/modify it under
90 the same terms as perl itself
91  
92 =head1 AUTHOR
93  
94 Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
95  
96 =head1 REPOSITORY INFORMATION
97  
98 $Rev: 851 $
99 $LastChangedBy: kutterma $
100 $Id: HTTP.pm 851 2009-05-15 22:45:18Z kutterma $
101 $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Transport/HTTP.pm $
102  
103 =cut
104  
« blib/lib/SOAP/WSDL/XSD/Schema.pm ↑ Summary blib/lib/SOAP/WSDL/XSD/Typelib/Builtin/anySimpleType.pm »