blib/lib/Plack/Middleware/BufferedStreaming.pm

filter: Statementstmt 100% 40 / 40 Branchbran 83.3% 5 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 100% 1 / 1 totaltotal 92.0% 58 / 63 CC 5 SCAR 6.6
CC
5
Cov
94%
call
4.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.9
« blib/lib/Plack/Middleware/NullLogger.pm ↑ Summary blib/lib/Plack/Middleware/AccessLog/Timed.pm »
1 package Plack::Middleware::BufferedStreaming;
2 39 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 39 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 39 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 39 ▶use Plack::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 39 ▶use Plack::Util::Accessor qw(force);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 39 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 39 ▶use parent qw(Plack::Middleware);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 39 ▶sub call {
Subroutine call: called CC=4 SCAR=13.9
Pod documented
11 39 my ( $self, $env ) = @_;
12  
13 39 my $caller_supports_streaming = $env->{'psgi.streaming'};
14 39 $env->{'psgi.streaming'} = Plack::Util::TRUE;
15  
16 39 my $res = $self->app->($env);
17 38 ▶ return $res if $caller_supports_streaming && !$self->force;
Branch: 1 branch
BranchTrueFalseTotal
if $caller_supports_streaming and not $self->force 0 38 38
Condition33%1/3
$caller_supports_streaming and not $self->force
!ll&&!rl&&r
3800
MC/DC0%0/2
$caller_supports_streaming and not $self->force
$caller_supports_streaming not $self->force
Truth table33%1/3
A and not(B)
A= $caller_supports_streamingB= not $self->force
ABresult
0X0
100
111
18  
19 38 ▶ if ( ref($res) eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $res eq 'CODE') { } 4 34 38
20 4 my $ret;
21  
22 4 ▶ $res->(sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
23 4 my $write = shift;
24  
25 4 ▶ if ( @$write == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$write == 2) { } 2 2 4
26 2 my @body;
27  
28 2 $ret = [ @$write, \@body ];
29  
30 return Plack::Util::inline_object(
31 4 ▶ write => sub { push @body, $_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
32 2 ▶ close => sub { },
Subroutine __ANON__: called CC=1 SCAR=0.0
33 2 );
34 } else {
35 2 $ret = $write;
36 2 return;
37 }
38 4 });
39  
40 4 return $ret;
41 } else {
42 34 return $res;
43 }
44 }
45  
46 39 1;
47  
48 __END__
« blib/lib/Plack/Middleware/NullLogger.pm ↑ Summary blib/lib/Plack/Middleware/AccessLog/Timed.pm »