line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::BufferedStreaming; |
2
|
39
|
|
|
39
|
|
274
|
use strict; |
|
39
|
|
|
|
|
116
|
|
|
39
|
|
|
|
|
2579
|
|
3
|
39
|
|
|
39
|
|
270
|
no warnings; |
|
39
|
|
|
|
|
573
|
|
|
39
|
|
|
|
|
1683
|
|
4
|
39
|
|
|
39
|
|
197
|
use Carp; |
|
39
|
|
|
|
|
77
|
|
|
39
|
|
|
|
|
3079
|
|
5
|
39
|
|
|
39
|
|
273
|
use Plack::Util; |
|
39
|
|
|
|
|
78
|
|
|
39
|
|
|
|
|
1145
|
|
6
|
39
|
|
|
39
|
|
197
|
use Plack::Util::Accessor qw(force); |
|
39
|
|
|
|
|
40
|
|
|
39
|
|
|
|
|
275
|
|
7
|
39
|
|
|
39
|
|
272
|
use Scalar::Util qw(weaken); |
|
39
|
|
|
|
|
78
|
|
|
39
|
|
|
|
|
1874
|
|
8
|
39
|
|
|
39
|
|
195
|
use parent qw(Plack::Middleware); |
|
39
|
|
|
|
|
116
|
|
|
39
|
|
|
|
|
159
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub call { |
11
|
39
|
|
|
39
|
1
|
790
|
my ( $self, $env ) = @_; |
12
|
|
|
|
|
|
|
|
13
|
39
|
|
|
|
|
570
|
my $caller_supports_streaming = $env->{'psgi.streaming'}; |
14
|
39
|
|
|
|
|
700
|
$env->{'psgi.streaming'} = Plack::Util::TRUE; |
15
|
|
|
|
|
|
|
|
16
|
39
|
|
|
|
|
1869
|
my $res = $self->app->($env); |
17
|
38
|
50
|
33
|
|
|
927
|
return $res if $caller_supports_streaming && !$self->force; |
18
|
|
|
|
|
|
|
|
19
|
38
|
100
|
|
|
|
1334
|
if ( ref($res) eq 'CODE' ) { |
20
|
4
|
|
|
|
|
23
|
my $ret; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$res->(sub { |
23
|
4
|
|
|
4
|
|
19
|
my $write = shift; |
24
|
|
|
|
|
|
|
|
25
|
4
|
100
|
|
|
|
15
|
if ( @$write == 2 ) { |
26
|
2
|
|
|
|
|
11
|
my @body; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
16
|
$ret = [ @$write, \@body ]; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return Plack::Util::inline_object( |
31
|
4
|
|
|
|
|
13
|
write => sub { push @body, $_[0] }, |
32
|
|
|
|
|
|
|
close => sub { }, |
33
|
2
|
|
|
|
|
48
|
); |
34
|
|
|
|
|
|
|
} else { |
35
|
2
|
|
|
|
|
4
|
$ret = $write; |
36
|
2
|
|
|
|
|
15
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
4
|
|
|
|
|
66
|
}); |
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
|
|
65
|
return $ret; |
41
|
|
|
|
|
|
|
} else { |
42
|
34
|
|
|
|
|
619
|
return $res; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |