line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::BufferedStreaming; |
2
|
39
|
|
|
39
|
|
234
|
use strict; |
|
39
|
|
|
|
|
39
|
|
|
39
|
|
|
|
|
975
|
|
3
|
39
|
|
|
39
|
|
156
|
no warnings; |
|
39
|
|
|
|
|
77
|
|
|
39
|
|
|
|
|
1147
|
|
4
|
39
|
|
|
39
|
|
157
|
use Carp; |
|
39
|
|
|
|
|
77
|
|
|
39
|
|
|
|
|
1756
|
|
5
|
39
|
|
|
39
|
|
195
|
use Plack::Util; |
|
39
|
|
|
|
|
77
|
|
|
39
|
|
|
|
|
793
|
|
6
|
39
|
|
|
39
|
|
157
|
use Plack::Util::Accessor qw(force); |
|
39
|
|
|
|
|
78
|
|
|
39
|
|
|
|
|
536
|
|
7
|
39
|
|
|
39
|
|
195
|
use Scalar::Util qw(weaken); |
|
39
|
|
|
|
|
457
|
|
|
39
|
|
|
|
|
1975
|
|
8
|
39
|
|
|
39
|
|
232
|
use parent qw(Plack::Middleware); |
|
39
|
|
|
|
|
78
|
|
|
39
|
|
|
|
|
194
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub call { |
11
|
39
|
|
|
39
|
1
|
1053
|
my ( $self, $env ) = @_; |
12
|
|
|
|
|
|
|
|
13
|
39
|
|
|
|
|
548
|
my $caller_supports_streaming = $env->{'psgi.streaming'}; |
14
|
39
|
|
|
|
|
299
|
$env->{'psgi.streaming'} = Plack::Util::TRUE; |
15
|
|
|
|
|
|
|
|
16
|
39
|
|
|
|
|
1437
|
my $res = $self->app->($env); |
17
|
38
|
50
|
33
|
|
|
828
|
return $res if $caller_supports_streaming && !$self->force; |
18
|
|
|
|
|
|
|
|
19
|
38
|
100
|
|
|
|
614
|
if ( ref($res) eq 'CODE' ) { |
20
|
4
|
|
|
|
|
69
|
my $ret; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$res->(sub { |
23
|
4
|
|
|
4
|
|
42
|
my $write = shift; |
24
|
|
|
|
|
|
|
|
25
|
4
|
100
|
|
|
|
32
|
if ( @$write == 2 ) { |
26
|
2
|
|
|
|
|
15
|
my @body; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
8
|
$ret = [ @$write, \@body ]; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return Plack::Util::inline_object( |
31
|
4
|
|
|
|
|
30
|
write => sub { push @body, $_[0] }, |
32
|
|
|
|
|
|
|
close => sub { }, |
33
|
2
|
|
|
|
|
62
|
); |
34
|
|
|
|
|
|
|
} else { |
35
|
2
|
|
|
|
|
4
|
$ret = $write; |
36
|
2
|
|
|
|
|
17
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
4
|
|
|
|
|
69
|
}); |
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
|
|
52
|
return $ret; |
41
|
|
|
|
|
|
|
} else { |
42
|
34
|
|
|
|
|
620
|
return $res; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |