Role/CHICaching/VaryNotAsterisk.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 26 / 26 CC 3 SCAR 6.2
CC
3
Cov
100%
cache_vary
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« Role/CHICaching.pm ↑ Summary Role/CHICaching/SimpleKeyGen.pm »
1 package LWP::UserAgent::Role::CHICaching::VaryNotAsterisk;
2  
3 1 ▶use 5.006000;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use CHI;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Types::Standard qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $AUTHORITY = 'cpan:KJETILK';
9 1 our $VERSION = '0.04';
10  
11 =pod
12  
13 =encoding utf-8
14  
15 =head1 NAME
16  
17 LWP::UserAgent::Role::CHICaching::VaryNotAsterisk - A role for when Vary is not * when caching LWP::UserAgent
18  
19 =head1 SYNOPSIS
20  
21 See L<LWP::UserAgent::Role::CHICaching>.
22  
23  
24 =head1 DESCRIPTION
25  
26 See L<LWP::UserAgent::Role::CHICaching::SimpleKeyGen> for a
27 background. Basically, this module does the second dumbest thing, but
28 in doing so, the User Agent ceases to be compliant with the HTTP
29 standard. You basically have to implement your own C<key> attribute to
30 make it compliant.
31  
32 =head2 Attributes and Methods
33  
34 =over
35  
36 =item C<< cache_vary >>
37  
38 Allow a response with a C<Vary> header to be cached if it doesn't
39 contain an asterisk (*).
40  
41 =back
42  
43 =cut
44  
45 5 ▶sub cache_vary {
Subroutine cache_vary: called CC=3 SCAR=11.0
Pod documented
46 5 my ($self, $res) = @_;
47 5 foreach my $vary ($res->header('Vary')) {
48 4 ▶ return 0 if ($vary =~ m/\*/);
Branch: 1 branch
BranchTrueFalseTotal
if $vary =~ /\*/ 2 2 4
49 }
50 3 return 1;
51 }
52  
53 1 1;
54  
55 __END__
« Role/CHICaching.pm ↑ Summary Role/CHICaching/SimpleKeyGen.pm »