| 1 | # ====================================================================== | ||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||
| 3 | # Copyright (C) 2000-2001 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 | # $Id: TCP.pm 384 2011-08-16 17:08:08Z kutterma $ | ||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||
| 9 | # ====================================================================== | ||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | package SOAP::Transport::TCP; | ||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 2 | our $VERSION = '1.27'; # VERSION | |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use URI; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use IO::Select; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use IO::SessionData; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | # ====================================================================== | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | package # hide from PAUSE | ||||||||||||||||||||||||||||||||
| 25 | URI::tcp; # ok, let's do 'tcp://' scheme | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 2 | our $VERSION = 0.715; | |||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 2 | require URI::_server; | |||||||||||||||||||||||||||||||
| 30 | 2 | @URI::tcp::ISA=qw(URI::_server); | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | # ====================================================================== | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | package SOAP::Transport::TCP::Client; | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 2 | our $VERSION = 0.715; | |||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 2 | ▶ | use vars qw(@ISA); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 39 | 2 | require SOAP::Lite; | |||||||||||||||||||||||||||||||
| 40 | 2 | @ISA = qw(SOAP::Client); | |||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | sub DESTROY { SOAP::Trace::objects('()') } | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=23.0
| |||||||||||||||||||||||||||||||||
| 45 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 4 | ▶ | unless (ref $self) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 48 | 1 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||
| 49 | 1 | my(@params, @methods); | |||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | while (@_) { $class->can($_[0]) ? push(@methods, shift() => shift) : push(@params, shift) } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 51 | 1 | $self = bless {@params} => $class; | |||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | while (@methods) { my($method, $params) = splice(@methods,0,2); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | $self->$method(ref $params eq 'ARRAY' ? @$params : $params) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | # use SSL if there is any parameter with SSL_* in the name | ||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | $self->SSL(1) if !$self->SSL && grep /^SSL_/, keys %$self; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $self->SSL and grep /^SSL_/, keys %$self
MC/DC0%0/2
not $self->SSL and grep /^SSL_/, keys %$self
not $self->SSL
grep /^SSL_/, keys %$self
Truth table33%1/3
not(A) and B
A= not $self->SSLB= grep /^SSL_/, keys %$self
| |||||||||||||||||||||||||||||||||
| 57 | 1 | SOAP::Trace::objects('()'); | |||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | 4 | return $self; | |||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | sub SSL { | ||||||||||||||||||||||||||||||
|
Subroutine
SSL: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||
| 63 | 2 | my $self = shift->new; | |||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | @_ ? ($self->{_SSL} = shift, return $self) : return $self->{_SSL}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | sub io_socket_class { shift->SSL ? 'IO::Socket::SSL' : 'IO::Socket::INET' } | ||||||||||||||||||||||||||||||
|
Subroutine
io_socket_class: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub syswrite { | ||||||||||||||||||||||||||||||
|
Subroutine
syswrite: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||
| 70 | 0 | my($self, $sock, $data) = @_; | |||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 0 | my $timeout = $sock->timeout; | |||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 0 | my $select = IO::Select->new($sock); | |||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 0 | my $len = length $data; | |||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | while (length $data > 0) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | return unless $select->can_write($timeout); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 79 | 0 | local $SIG{PIPE} = 'IGNORE'; | |||||||||||||||||||||||||||||||
| 80 | # added length() to make it work on Mac. Thanks to Robin Fuller <rfuller@broadjump.com> | ||||||||||||||||||||||||||||||||
| 81 | 0 | my $wc = syswrite($sock, $data, length($data)); | |||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if (defined $wc) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 83 | 0 | substr($data, 0, $wc) = ''; | |||||||||||||||||||||||||||||||
| 84 | } elsif (!IO::SessionData::WOULDBLOCK($!)) { | ||||||||||||||||||||||||||||||||
| 85 | 0 | return; | |||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||
| 88 | 0 | return $len; | |||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub sysread { | ||||||||||||||||||||||||||||||
|
Subroutine
sysread: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||
| 92 | 0 | my($self, $sock) = @_; | |||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 0 | my $timeout = $sock->timeout; | |||||||||||||||||||||||||||||||
| 95 | 0 | my $select = IO::Select->new($sock); | |||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | 0 | my $result = ''; | |||||||||||||||||||||||||||||||
| 98 | 0 | my $data; | |||||||||||||||||||||||||||||||
| 99 | 0 | while (1) { | |||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | return unless $select->can_read($timeout); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 101 | 0 | my $rc = sysread($sock, $data, 4096); | |||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if ($rc) { | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 103 | 0 | $result .= $data; | |||||||||||||||||||||||||||||||
| 104 | } elsif (defined $rc) { | ||||||||||||||||||||||||||||||||
| 105 | 0 | return $result; | |||||||||||||||||||||||||||||||
| 106 | } elsif (!IO::SessionData::WOULDBLOCK($!)) { | ||||||||||||||||||||||||||||||||
| 107 | 0 | return; | |||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | sub send_receive { | ||||||||||||||||||||||||||||||
|
Subroutine
send_receive: called CC=13 SCAR=33.3
| |||||||||||||||||||||||||||||||||
| 113 | 1 | my($self, %parameters) = @_; | |||||||||||||||||||||||||||||||
| 114 | my($envelope, $endpoint, $action) = | ||||||||||||||||||||||||||||||||
| 115 | 1 | @parameters{qw(envelope endpoint action)}; | |||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | $endpoint ||= $self->endpoint; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$endpoint ||= $self->endpoint
MC/DC0%0/2
$endpoint ||= $self->endpoint
$endpoint
$self->endpoint
Truth table33%1/3
A ||= B
A= $endpointB= $self->endpoint
| |||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | warn "URLs with 'tcp:' scheme are deprecated. Use 'tcp://'. Still continue\n" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$endpoint =~ s[^tcp:(//)?][tcp://]i and not $1
MC/DC0%0/2
$endpoint =~ s[^tcp:(//)?][tcp://]i and not $1
$endpoint =~ s[^tcp:(//)?][tcp://]i
not $1
Truth table33%1/3
A and not(B)
A= $endpoint =~ s[^tcp:(//)?][tcp://]iB= not $1
| |||||||||||||||||||||||||||||||||
| 119 | if $endpoint =~ s!^tcp:(//)?!tcp://!i && !$1; | ||||||||||||||||||||||||||||||||
| 120 | 1 | my $uri = URI->new($endpoint); | |||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | 1 | local($^W, $@, $!); | |||||||||||||||||||||||||||||||
| 123 | 1 | my $socket = $self->io_socket_class; | |||||||||||||||||||||||||||||||
| 124 | 1 | ▶ | eval "require $socket" or Carp::croak $@ unless UNIVERSAL::can($socket => 'new'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
UNIVERSAL::can($socket, 'new') || (eval "require $socket" || Carp::croak($@))
eval "require $socket" or Carp::croak($@)
MC/DC0%0/2
UNIVERSAL::can($socket, 'new') || (eval "require $socket" || Carp::croak($@))
UNIVERSAL::can($socket, 'new')
eval "require $socket"
Truth table33%1/3
A || B
A= UNIVERSAL::can($socket, 'new')B= eval "require $socket"
| |||||||||||||||||||||||||||||||||
| 125 | 1 | my $sock = $socket->new ( | |||||||||||||||||||||||||||||||
| 126 | PeerAddr => $uri->host, PeerPort => $uri->port, Proto => $uri->scheme, %$self | ||||||||||||||||||||||||||||||||
| 127 | ); | ||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||
| 129 | 1 | SOAP::Trace::debug($envelope); | |||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||
| 131 | # bytelength hack. See SOAP::Transport::HTTP.pm for details. | ||||||||||||||||||||||||||||||||
| 132 | 1 | my $bytelength = SOAP::Utils::bytelength($envelope); | |||||||||||||||||||||||||||||||
| 133 | 1 | ▶ | $envelope = pack('C0A*', $envelope) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $SOAP::Constants::DO_NOT_USE_LWP_LENGTH_HACK and length $envelope != $bytelength
MC/DC0%0/2
not $SOAP::Constants::DO_NOT_USE_LWP_LENGTH_HACK and length $envelope != $bytelength
not $SOAP::Constants::DO_NOT_USE_LWP_LENGTH_HACK
length $envelope != $bytelength
Truth table33%1/3
not(A) and B
A= not $SOAP::Constants::DO_NOT_USE_LWP_LENGTH_HACKB= length $envelope != $bytelength
| |||||||||||||||||||||||||||||||||
| 134 | if !$SOAP::Constants::DO_NOT_USE_LWP_LENGTH_HACK && length($envelope) != $bytelength; | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | 1 | my $result; | |||||||||||||||||||||||||||||||
| 137 | 1 | ▶ | if ($sock) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 138 | 0 | $sock->blocking(0); | |||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | $self->syswrite($sock, $envelope) and | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->syswrite($sock, $envelope) and $sock->shutdown(1)
MC/DC0%0/2
$self->syswrite($sock, $envelope) and $sock->shutdown(1)
$self->syswrite($sock, $envelope)
$sock->shutdown(1)
Truth table0%0/3
A and B
A= $self->syswrite($sock, $envelope)B= $sock->shutdown(1)
| |||||||||||||||||||||||||||||||||
| 140 | $sock->shutdown(1) and # stop writing | ||||||||||||||||||||||||||||||||
| 141 | $result = $self->sysread($sock); | ||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | 1 | SOAP::Trace::debug($result); | |||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | 1 | ▶ | my $code = $@ || $!; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$@ || $!
MC/DC0%0/2
$@ || $!
$@
$!
Truth table33%1/3
A || B
A= $@B= $!
| |||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | 1 | $self->code($code); | |||||||||||||||||||||||||||||||
| 149 | 1 | $self->message($code); | |||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | $self->is_success(!defined $code || $code eq ''); | ||||||||||||||||||||||||||||||
|
Condition33%1/3
!defined($code) || $code eq ''
MC/DC0%0/2
!defined($code) || $code eq ''
!defined($code)
$code eq ''
Truth table33%1/3
not(A) || B
A= !defined($code)B= $code eq ''
| |||||||||||||||||||||||||||||||||
| 151 | 1 | $self->status($code); | |||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | 1 | return $result; | |||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | # ====================================================================== | ||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | package SOAP::Transport::TCP::Server; | ||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||
| 160 | 2 | ▶ | use IO::SessionSet; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | 2 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 163 | 2 | ▶ | use vars qw($AUTOLOAD @ISA); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 164 | 2 | @ISA = qw(SOAP::Server); | |||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||
| 166 | 2 | our $VERSION = 0.715; | |||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub DESTROY { SOAP::Trace::objects('()') } | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||
| 171 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | unless (ref $self) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||
| 176 | 0 | my(@params, @methods); | |||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | while (@_) { $class->can($_[0]) ? push(@methods, shift() => shift) : push(@params, shift) } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 178 | 0 | $self = $class->SUPER::new(@methods); | |||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||
| 180 | # use SSL if there is any parameter with SSL_* in the name | ||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $self->SSL(1) if !$self->SSL && grep /^SSL_/, @params; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->SSL and grep /^SSL_/, @params
MC/DC0%0/2
not $self->SSL and grep /^SSL_/, @params
not $self->SSL
grep /^SSL_/, @params
Truth table0%0/3
not(A) and B
A= not $self->SSLB= grep /^SSL_/, @params
| |||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | 0 | my $socket = $self->io_socket_class; | |||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | eval "require $socket" or Carp::croak $@ unless UNIVERSAL::can($socket => 'new'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
UNIVERSAL::can($socket, 'new') || (eval "require $socket" || Carp::croak($@))
eval "require $socket" or Carp::croak($@)
MC/DC0%0/2
UNIVERSAL::can($socket, 'new') || (eval "require $socket" || Carp::croak($@))
UNIVERSAL::can($socket, 'new')
eval "require $socket"
Truth table0%0/3
A || B
A= UNIVERSAL::can($socket, 'new')B= eval "require $socket"
| |||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $self->{_socket} = $socket->new(Proto => 'tcp', @params) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 186 | or Carp::croak "Can't open socket: $!"; | ||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | 0 | SOAP::Trace::objects('()'); | |||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||
| 190 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub SSL { | ||||||||||||||||||||||||||||||
|
Subroutine
SSL: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 194 | 0 | my $self = shift->new; | |||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | @_ ? ($self->{_SSL} = shift, return $self) : return $self->{_SSL}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | sub io_socket_class { shift->SSL ? 'IO::Socket::SSL' : 'IO::Socket::INET' } | ||||||||||||||||||||||||||||||
|
Subroutine
io_socket_class: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=2 SCAR=12.2
| |||||||||||||||||||||||||||||||||
| 201 | 0 | my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::') + 2); | |||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | return if $method eq 'DESTROY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||
| 204 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | *$AUTOLOAD = sub { shift->{_socket}->$method(@_) }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 206 | 0 | goto &$AUTOLOAD; | |||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub handle { | ||||||||||||||||||||||||||||||
|
Subroutine
handle: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 210 | 0 | my $self = shift->new; | |||||||||||||||||||||||||||||||
| 211 | 0 | my $sock = $self->{_socket}; | |||||||||||||||||||||||||||||||
| 212 | 0 | my $session_set = IO::SessionSet->new($sock); | |||||||||||||||||||||||||||||||
| 213 | 0 | my %data; | |||||||||||||||||||||||||||||||
| 214 | 0 | while (1) { | |||||||||||||||||||||||||||||||
| 215 | 0 | my @ready = $session_set->wait($sock->timeout); | |||||||||||||||||||||||||||||||
| 216 | 0 | for my $session (grep { defined } @ready) { | |||||||||||||||||||||||||||||||
| 217 | 0 | my $data; | |||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if (my $rc = $session->read($data, 4096)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | $data{$session} .= $data if $rc > 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 220 | } else { | ||||||||||||||||||||||||||||||||
| 221 | 0 | $session->write($self->SUPER::handle(delete $data{$session})); | |||||||||||||||||||||||||||||||
| 222 | 0 | $session->close; | |||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||
| 228 | # ====================================================================== | ||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||
| 230 | 2 | 1; | |||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||
| 232 | __END__ | ||||||||||||||||||||||||||||||||