SockJS/Transport/XHRStreaming.pm

filter: Statementstmt 91.6% 44 / 48 Branchbran 75.0% 6 / 8 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 83.7% 62 / 74 CC 7 SCAR 10.3
CC
7
Cov
87%
__ANON__
5.1
__ANON__
2.3
new
2.0
CRAP 2.8
« SockJS/Exception.pm ↑ Summary SockJS/Transport/XHRPolling.pm »
1 package SockJS::Transport::XHRStreaming;
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=2 SCAR=7.0
Pod undocumented
9 3 my $self = shift->SUPER::new(@_);
10 3 my (%params) = @_;
11  
12 3 ▶ $self->{response_limit} = $params{response_limit} || 128 * 1024;
Condition50%1/2
$params{'response_limit'} || 131072
l!l
03
MC/DC0%0/1
$params{'response_limit'} || 131072
$params{'response_limit'}
Truth table50%1/2
A
A= $params{'response_limit'}
Aresult
11
00
13  
14 3 push @{$self->{allowed_methods}}, 'POST';
15  
16 3 return $self;
17 }
18  
19 3 ▶sub dispatch_POST {
Subroutine dispatch_POST: called CC=1 SCAR=0.0
Pod undocumented
20 3 my $self = shift;
21 3 my ($env, $conn) = @_;
22  
23 3 my $limit = $self->{response_limit};
24  
25 3 ▶ return sub {
Subroutine __ANON__: called CC=5 SCAR=16.4
26 3 my $respond = shift;
27  
28 3 my $writer = $respond->(
29 [
30 200,
31 [ 'Content-Type' => 'application/javascript; charset=UTF-8' ]
32 ]
33 );
34  
35 3 $writer->write(('h' x 2048) . "\n");
36  
37 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
38 1 $writer->write('c[2010,"Another connection still open"]' . "\n");
39 1 $writer->write('');
40 1 $writer->close;
41 1 return;
42 }
43  
44 $conn->write_cb(
45 2 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=8.1
46 2 my $conn = shift;
47 2 my ($message) = @_;
48  
49 2 $writer->write($message . "\n");
50  
51 2 $limit -= length($message) - 1;
52  
53 2 ▶ if ($limit <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($limit <= 0) 0 2 2
54 0 $writer->write('');
55 0 $writer->close;
56  
57 0 $conn->reconnecting;
58 }
59 }
60 2 );
61  
62 $conn->close_cb(
63 1 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
64 1 my $conn = shift;
65  
66 1 $writer->write('');
67 1 $writer->close;
68 }
69 2 );
70  
71 2 ▶ if ($conn->is_closed) {
Branch: 2 branches
BranchTrueFalseTotal
if ($conn->is_closed) { } 1 1 2
elsif ($conn->is_connected) { } 0 1 1
72 1 $conn->connected;
73 1 $conn->close;
74 }
75 elsif ($conn->is_connected) {
76 0 $conn->reconnected;
77 }
78 else {
79 1 $limit -= 4;
80 1 $conn->write('o');
81  
82 1 $conn->connected;
83 }
84 3 };
85 }
86  
87 1 1;
« SockJS/Exception.pm ↑ Summary SockJS/Transport/XHRPolling.pm »