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

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