HTTP/_ClientOperation.pm

filter: Statementstmt 91.6% 33 / 36 Branchbran 75.0% 9 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 7 totaltotal 78.7% 52 / 66 CC 7 SCAR 8.3
CC
7
Cov
88%
cancel
4.2
_cancel_timer
3.0
websocket
2.0
CRAP 2.3
« HTTP/_Session.pm ↑ Summary HTTP.pm »
1 package Unblock::HTTP::_ClientOperation;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 503 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8 503 my ($class, $client, $request, $callbacks, $version, $origin) = @_;
9 503 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 503 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 503 weaken($self->{origin});
26 503 return $self;
27 }
28  
29 110 ▶sub state { $_[0]{state} }
Subroutine state: called CC=1 SCAR=0.0
Pod undocumented
30 4 ▶sub error { $_[0]{error} }
Subroutine error: called CC=1 SCAR=0.0
Pod undocumented
31 552 ▶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 804 ▶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 796 804
34  
35 502 ▶sub _cancel_timer {
Subroutine _cancel_timer: called CC=3 SCAR=11.0
36 502 my ($self) = @_;
37 502 ▶ my $cancel = delete $self->{timer_cancel} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $cancel = delete $self->{"timer_cancel"} or return 7 495 502
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 14 ▶sub cancel {
Subroutine cancel: called CC=4 SCAR=14.5
Pod undocumented
43 14 my ($self) = @_;
44 14 ▶ return 0 if $self->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_terminal 6 8 14
45 8 ▶ if (my $tx = $self->{transaction}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tx = $self->{"transaction"}) 0 8 8
46 0 $tx->cancel;
47 0 return 1;
48 }
49 8 $self->{state} = 'cancelled';
50 8 $self->_cancel_timer;
51 8 my $client = $self->{client};
52 8 ▶ $client->_cancel_queued($self) if $client;
Branch: 1 branch
BranchTrueFalseTotal
if $client 8 0 8
53 8 return 1;
54 }
55  
56 10 1;
57  
58 __END__
« HTTP/_Session.pm ↑ Summary HTTP.pm »