File Coverage

blib/lib/Plack/App/CGIBin/Streaming/IO.pm
Criterion Covered Total %
statement 21 24 87.5
branch 5 10 50.0
condition 2 6 33.3
subroutine 9 10 90.0
pod 0 2 0.0
total 37 52 71.1


line stmt bran cond sub pod time code
1             package Plack::App::CGIBin::Streaming::IO;
2              
3 22     22   365 use 5.014;
  22         68  
  22         719  
4 22     22   114 use strict;
  22         31  
  22         570  
5 22     22   98 use warnings;
  22         38  
  22         521  
6 22     22   158 use Plack::App::CGIBin::Streaming;
  22         37  
  22         5955  
7              
8             sub PUSHED {
9             #my ($class, $mode, $fh) = @_;
10              
11 66     66 0 18433 return bless +{read_mode => (substr($_[1], 0, 1) eq 'r')}, $_[0];
12             }
13              
14             sub WRITE {
15             #my ($self, $buf, $fh) = @_;
16              
17 3244     3244   42291 $Plack::App::CGIBin::Streaming::R->print_content($_[1]);
18 3244         12386 return length $_[1];
19             }
20              
21             sub FLUSH {
22             #my ($self, $fh) = @_;
23              
24 83 100 66 83 0 4032 return 0 if $_[0]->{in_flush} or $_[0]->{read_mode};
25 58         144 local $_[0]->{in_flush}=1;
26              
27 58 100       193 $Plack::App::CGIBin::Streaming::R->flush
28             unless $Plack::App::CGIBin::Streaming::R->suppress_flush;
29              
30 58         237 return 0;
31             }
32              
33             sub READ {
34             #my ($self, $buf, $len, $fh) = @_;
35              
36 9     9   148 return $_[3]->read($_[1], $_[2]);
37             }
38              
39             sub SEEK {
40             #my ($self, $pos, $whence, $fh) = @_;
41              
42 0 0 0 0   0 return -1
43             unless ($_[0]->{read_mode} and
44             $Plack::App::CGIBin::Streaming::R->env->{'psgix.input.buffered'});
45              
46 0 0       0 return $_[3]->seek($_[1], $_[2]) ? 0 : -1;
47             }
48              
49             sub BINMODE {
50             #my ($self, $fh) = @_;
51              
52             # pop the layer when we are done
53 66 50   66   217 return if $Plack::App::CGIBin::Streaming::R->binmode_ok;
54              
55             # otherwise keep it
56 0           return 0;
57             }
58              
59             1;
60              
61             __END__