SockJS/Transport/XHRPolling.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 89.4% 51 / 57 CC 5 SCAR 9.9
CC
5
Cov
93%
__ANON__
5.0
dispatch_POST
1.0
BEGIN
1.0
CRAP 2.7
« SockJS/Transport/XHRStreaming.pm ↑ Summary SockJS/Middleware/JSessionID.pm »
1 package SockJS::Transport::XHRPolling;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base 'SockJS::Transport::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
9 3 my $self = shift->SUPER::new(@_);
10  
11 3 push @{$self->{allowed_methods}}, 'POST';
12  
13 3 return $self;
14 }
15  
16 3 ▶sub dispatch_POST {
Subroutine dispatch_POST: called CC=1 SCAR=0.0
Pod undocumented
17 3 my $self = shift;
18 3 my ($env, $conn) = @_;
19  
20 3 ▶ return sub {
Subroutine __ANON__: called CC=5 SCAR=16.2
21 3 my $respond = shift;
22  
23 3 ▶ if ($conn->is_connected && !$conn->is_reconnecting) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->is_connected and not $conn->is_reconnecting) 1 2 3
Condition66%2/3
$conn->is_connected and not $conn->is_reconnecting
!ll&&!rl&&r
201
MC/DC50%1/2
$conn->is_connected and not $conn->is_reconnecting
$conn->is_connected not $conn->is_reconnecting
Truth table66%2/3
A and not(B)
A= $conn->is_connectedB= not $conn->is_reconnecting
ABresult
0X0
100
111
24 1 $self->_write($env, $respond,
25 'c[2010,"Another connection still open"]');
26 1 return;
27 }
28  
29 $conn->write_cb(
30 2 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
31 2 my $conn = shift;
32 2 my ($message) = @_;
33  
34 2 $self->_write($env, $respond, $message);
35 2 $conn->reconnecting;
36 }
37 2 );
38  
39 2 ▶ if ($conn->is_closed) {
Branch: 2 branches
BranchTrueFalseTotal
if ($conn->is_closed) { } 1 1 2
elsif ($conn->is_connected) { } 0 1 1
40 1 $conn->connected;
41 1 $conn->close;
42 }
43 elsif ($conn->is_connected) {
44 0 $conn->reconnected;
45 }
46 else {
47 1 $conn->write('o');
48  
49 1 $conn->connected;
50 }
51 3 };
52 }
53  
54 3 ▶sub _write {
Subroutine _write: called CC=1 SCAR=0.0
55 3 my $self = shift;
56 3 my ($env, $respond, $message) = @_;
57  
58 3 $message .= "\n";
59  
60 3 $respond->(
61 [
62 200, [ 'Content-Type' => 'application/javascript; charset=UTF-8', ],
63 [$message]
64 ]
65 );
66 }
67  
68 1 1;
« SockJS/Transport/XHRStreaming.pm ↑ Summary SockJS/Middleware/JSessionID.pm »