line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bootylicious::Plugin::HttpCache; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1480
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
88
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Mojo::ByteStream; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
197
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub register { |
11
|
1
|
|
|
1
|
1
|
32
|
my ($self, $app) = @_; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$app->hook( |
14
|
|
|
|
|
|
|
after_dispatch => sub { |
15
|
3
|
|
|
3
|
|
31341
|
my $self = shift; |
16
|
|
|
|
|
|
|
|
17
|
3
|
100
|
|
|
|
10
|
return unless $self->req->method eq 'GET'; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
36
|
my $body = $self->res->body; |
20
|
2
|
50
|
|
|
|
52
|
return unless defined $body; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
13
|
my $our_etag = Mojo::ByteStream->new($body)->md5_sum; |
23
|
2
|
|
|
|
|
33
|
$self->res->headers->header('ETag' => $our_etag); |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
|
|
75
|
my $browser_etag = $self->req->headers->header('If-None-Match'); |
26
|
2
|
100
|
66
|
|
|
52
|
return unless $browser_etag && $browser_etag eq $our_etag; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
11
|
$self->res->code(304); |
29
|
1
|
|
|
|
|
14
|
$self->res->body(''); |
30
|
|
|
|
|
|
|
} |
31
|
1
|
|
|
|
|
9
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |