HTTP/_ClientOperation.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 83.3% 10 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 7 totaltotal 83.3% 55 / 66 CC 7 SCAR 8.1
CC
7
Cov
94%
cancel
4.0
_cancel_timer
3.0
websocket
2.0
CRAP 2.2
« HTTP/_Session.pm ↑ Summary HTTP.pm »
1 package Unblock::HTTP::_ClientOperation;
2  
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 510 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8 510 my ($class, $client, $request, $callbacks, $version, $origin) = @_;
9 510 my $self = bless {
10 client => $client,
11 request => $request,
12 callbacks => $callbacks,
13 version => $version,
14 origin => $origin,
15 state => 'queued',
16 error => undef,
17 transaction => undef,
18 timer_cancel => undef,
19 timeout_error => undef,
20 }, $class;
21 510 weaken($self->{client});
22 # The Client owns its pools and their active/queued work. A retained
23 # completed handle must not keep the entire pool and unrelated
24 # connections alive through its private origin bookkeeping.
25 510 weaken($self->{origin});
26 510 return $self;
27 }
28  
29 115 ▶sub state { $_[0]{state} }
Subroutine state: called CC=1 SCAR=0.0
Pod undocumented
30 5 ▶sub error { $_[0]{error} }
Subroutine error: called CC=1 SCAR=0.0
Pod undocumented
31 558 ▶sub transaction { $_[0]{transaction} }
Subroutine transaction: called CC=1 SCAR=0.0
Pod undocumented
32 0 ▶sub websocket { $_[0]{websocket} }
Subroutine websocket: not called CC=1 SCAR=6.9
Pod undocumented
33 1323 ▶sub is_terminal { $_[0]{state} =~ /\A(?:complete|error|cancelled)\z/ ? 1 : 0 }
Subroutine is_terminal: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'state'} =~ /\A(?:complete|error|cancelled)\z/ ? : 8 1315 1323
34  
35 508 ▶sub _cancel_timer {
Subroutine _cancel_timer: called CC=3 SCAR=11.0
36 508 my ($self) = @_;
37 508 ▶ my $cancel = delete $self->{timer_cancel} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $cancel = delete $self->{"timer_cancel"} or return 7 501 508
38 7 ▶ eval { $cancel->(); 1 } or warn "request timer cancellation failed: $@";
Branch: 1 branch
BranchTrueFalseTotal
eval { do { &$cancel(); 1 } } or warn "request timer cancellation failed: $@" 7 0 7
39 7 return;
40 }
41  
42 16 ▶sub cancel {
Subroutine cancel: called CC=4 SCAR=13.9
Pod undocumented
43 16 my ($self) = @_;
44 16 ▶ return 0 if $self->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_terminal 6 10 16
45 10 ▶ if (my $tx = $self->{transaction}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tx = $self->{"transaction"}) 1 9 10
46 1 $tx->cancel;
47 1 return 1;
48 }
49 9 $self->{state} = 'cancelled';
50 9 $self->_cancel_timer;
51 9 my $client = $self->{client};
52 9 ▶ $client->_cancel_queued($self) if $client;
Branch: 1 branch
BranchTrueFalseTotal
if $client 9 0 9
53 9 return 1;
54 }
55  
56 12 1;
57  
58 __END__
« HTTP/_Session.pm ↑ Summary HTTP.pm »