line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::ResponseHelper::Attachment; |
2
|
1
|
|
|
1
|
|
14
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1055
|
use Plack::Response; |
|
1
|
|
|
|
|
53163
|
|
|
1
|
|
|
|
|
144
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub helper { |
9
|
1
|
|
|
1
|
0
|
3
|
my $init = shift; |
10
|
1
|
|
50
|
|
|
11
|
my $content_type = $init && $init->{content_type} || 'application/octet-stream'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
return sub { |
13
|
1
|
|
|
1
|
|
1
|
my $r = shift; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
11
|
my $response = Plack::Response->new(200); |
16
|
1
|
|
|
|
|
34
|
$response->headers( |
17
|
|
|
|
|
|
|
[ |
18
|
|
|
|
|
|
|
'Content-Type' => $content_type, |
19
|
|
|
|
|
|
|
'Content-Disposition' => qq[attachment; filename="$r->{filename}"], |
20
|
|
|
|
|
|
|
], |
21
|
|
|
|
|
|
|
); |
22
|
1
|
|
|
|
|
122
|
$response->body($r->{data}); |
23
|
1
|
|
|
|
|
7
|
return $response; |
24
|
1
|
|
|
|
|
8
|
}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__END__ |