line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::P3P; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Add standard (or custom) P3P header to response |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
690
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
7
|
1
|
|
|
1
|
|
16
|
use parent qw/Plack::Middleware/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
60
|
use Plack::Util::Accessor qw/policies/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub prepare_app { |
13
|
6
|
|
|
6
|
1
|
3697
|
my $self = shift; |
14
|
6
|
100
|
66
|
|
|
17
|
if (!defined $self->policies) { |
|
|
100
|
|
|
|
|
|
15
|
2
|
|
|
|
|
101
|
$self->policies('CAO PSA OUR'); |
16
|
|
|
|
|
|
|
} elsif (ref $self->policies && ref $self->policies eq 'ARRAY') { |
17
|
2
|
|
|
|
|
34
|
$self->policies(join ' ', @{$self->policies}); |
|
2
|
|
|
|
|
5
|
|
18
|
|
|
|
|
|
|
} |
19
|
6
|
|
|
|
|
62
|
$self->policies('CP="' . $self->policies . '"'); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub call { |
23
|
6
|
|
|
6
|
1
|
26359
|
my ($self, $env) = @_; |
24
|
|
|
|
|
|
|
$self->response_cb($self->app->($env), sub{ |
25
|
6
|
|
|
6
|
|
208
|
my $res = shift; |
26
|
6
|
|
|
|
|
15
|
Plack::Util::header_set($res->[1], 'P3P', $self->policies); |
27
|
6
|
|
|
|
|
25
|
}); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |