| 1 | 3 | ▶ | use strictures 2; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | package Dancer2::Plugin::ConditionalCaching; | ||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: RFC7234 Caching | ||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Dancer2::Plugin; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use HTTP::Headers::Fancy; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use HTTP::Date qw(time2str str2time); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use HTTP::Exception; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use Time::HiRes qw(time); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use Math::Round qw(round); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | 3 | our $VERSION = '0.001'; # VERSION | |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub _instanceof { | ||||||||||||||||||||||||||||||||
|
Subroutine
_instanceof: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 18 | 0 | my ( $obj, @cls ) = @_; | |||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | return 0 unless blessed $obj; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 20 | 0 | foreach my $cls (@cls) { | |||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | $cls = blessed $cls if blessed $cls; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | return 1 if $obj->isa($cls); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||
| 24 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub _cmp_weak { | ||||||||||||||||||||||||||||||||
|
Subroutine
_cmp_weak: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||
| 28 | 0 | my ( $a, $b, $w ) = @_; | |||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | return unless defined $a; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | return unless defined $b; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $w //= 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$w //= 0
MC/DC0%0/1
$w //= 0
$w
Truth table0%0/2
A
A= $w
| |||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ($w) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if ( ref $b ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 34 | 0 | return $a eq $$b; | |||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||
| 36 | else { | ||||||||||||||||||||||||||||||||||
| 37 | 0 | return $a eq $b; | |||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||
| 40 | else { | ||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | return 0 if ref $b; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 42 | 0 | return $a eq $b; | |||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||
| 46 | 17 | ▶ | register caching => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=67 SCAR=83.9
| |||||||||||||||||||||||||||||||||||
| 47 | 17 | my $dsl = shift; | |||||||||||||||||||||||||||||||||
| 48 | 17 | my %args = @_; | |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | 17 | my $get_or_head = $dsl->request->method =~ m{^(?:get|head)$}i; | |||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | my $dry = delete $args{dry} // 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{"dry"} // 0
MC/DC0%0/1
delete $args{"dry"} // 0
delete $args{"dry"}
Truth table0%0/2
A
A= delete $args{"dry"}
| |||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $force = delete $args{force} // 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{"force"} // 0
MC/DC0%0/1
delete $args{"force"} // 0
delete $args{"force"}
Truth table0%0/2
A
A= delete $args{"force"}
| |||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my $throw = delete $args{throw} // 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{"throw"} // 0
MC/DC0%0/1
delete $args{"throw"} // 0
delete $args{"throw"}
Truth table0%0/2
A
A= delete $args{"throw"}
| |||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | my $check = delete $args{check} // 1; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{"check"} // 1
MC/DC0%0/1
delete $args{"check"} // 1
delete $args{"check"}
Truth table0%0/2
A
A= delete $args{"check"}
| |||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||
| 58 | 0 | my $etag = delete $args{etag}; | |||||||||||||||||||||||||||||||||
| 59 | 0 | my $weak = !!delete $args{weak}; | |||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | 0 | my $changed = delete $args{changed}; | |||||||||||||||||||||||||||||||||
| 62 | 0 | my $expires = delete $args{expires}; | |||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | my $no_cache = ( ( delete $args{cache} // 1 ) == 0 ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{"cache"} // 1
MC/DC0%0/1
delete $args{"cache"} // 1
delete $args{"cache"}
Truth table0%0/2
A
A= delete $args{"cache"}
| |||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my $no_store = ( ( delete $args{store} // 1 ) == 0 ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{"store"} // 1
MC/DC0%0/1
delete $args{"store"} // 1
delete $args{"store"}
Truth table0%0/2
A
A= delete $args{"store"}
| |||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | my $private = ( delete $args{private} // 0 ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{"private"} // 0
MC/DC0%0/1
delete $args{"private"} // 0
delete $args{"private"}
Truth table0%0/2
A
A= delete $args{"private"}
| |||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $public = ( delete $args{public} // 0 ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{"public"} // 0
MC/DC0%0/1
delete $args{"public"} // 0
delete $args{"public"}
Truth table0%0/2
A
A= delete $args{"public"}
| |||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ( $private and $public ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$private and $public
MC/DC0%0/2
$private and $public
$private
$public
Truth table0%0/3
A and B
A= $privateB= $public
| |||||||||||||||||||||||||||||||||||
| 71 | 0 | warn "Cache-Control: private and public are mutually exclusive"; | |||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ($no_cache) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($no_store) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 75 | 0 | warn "Cache-Control: no-cache and no-store are mutually exclusive"; | |||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ($private) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 78 | 0 | warn "Cache-Control: no-cache and private are useless together"; | |||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($private) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 81 | 0 | warn "Cache-Control: no-cache and private are useless together"; | |||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||
| 85 | 0 | my %reqh = HTTP::Headers::Fancy::decode_hash( $dsl->request->headers ); | |||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | 0 | my %req_cc = HTTP::Headers::Fancy::split_field_hash( $reqh{CacheControl} ); | |||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||
| 89 | 0 | my ( $age, $fresh ); | |||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | $age = time - $changed if defined $changed; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | $fresh = $expires - time if defined $expires; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ( defined $age and $age < 0 ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $age and $age < 0
MC/DC0%0/2
defined $age and $age < 0
defined $age
$age < 0
Truth table0%0/3
A and B
A= defined $ageB= $age < 0
| |||||||||||||||||||||||||||||||||||
| 95 | 0 | warn("Age: 'changed' points to a timestamp in the future"); | |||||||||||||||||||||||||||||||||
| 96 | 0 | $age = 0; | |||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||
| 99 | 0 | my %resp_cc = ( | |||||||||||||||||||||||||||||||||
| 100 | ( NoCache => undef ) x !!$no_cache, | ||||||||||||||||||||||||||||||||||
| 101 | ( NoStore => undef ) x !!$no_store, | ||||||||||||||||||||||||||||||||||
| 102 | ( Private => undef ) x !!$private, | ||||||||||||||||||||||||||||||||||
| 103 | ( Public => undef ) x !!$public, | ||||||||||||||||||||||||||||||||||
| 104 | MustRevalidate => undef, | ||||||||||||||||||||||||||||||||||
| 105 | NoTransform => undef, | ||||||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ($check) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ( $req_cc{MaxAge} and defined $age ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$req_cc{"MaxAge"} and defined $age
MC/DC0%0/2
$req_cc{"MaxAge"} and defined $age
$req_cc{"MaxAge"}
defined $age
Truth table0%0/3
A and B
A= $req_cc{"MaxAge"}B= defined $age
| |||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ( $age > $req_cc{MaxAge} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 111 | 0 | $force = 1; | |||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( $req_cc{MinFresh} and defined $fresh ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$req_cc{"MinFresh"} and defined $fresh
MC/DC0%0/2
$req_cc{"MinFresh"} and defined $fresh
$req_cc{"MinFresh"}
defined $fresh
Truth table0%0/3
A and B
A= $req_cc{"MinFresh"}B= defined $fresh
| |||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ( $fresh < $req_cc{MinFresh} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 116 | 0 | $force = 1; | |||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my $builder = sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | return unless defined $args{builder}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 123 | 0 | my $sub; | |||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ( ref $args{builder} eq 'CODE' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 125 | 0 | $sub = delete $args{builder}; | |||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||
| 127 | else { | ||||||||||||||||||||||||||||||||||
| 128 | 0 | my $data = delete $args{builder}; | |||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | $sub = sub { return $data }; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||
| 131 | 0 | my %subargs = ( %req_cc, Force => $force, ); | |||||||||||||||||||||||||||||||||
| 132 | 0 | return $sub->(%subargs); | |||||||||||||||||||||||||||||||||
| 133 | 0 | }; | |||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||
| 135 | 0 | my %resph; | |||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if ( keys %resp_cc ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 138 | 0 | $resph{CacheControl} = HTTP::Headers::Fancy::build_field_hash(%resp_cc); | |||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ( defined $age ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 141 | 0 | $resph{Age} = round($age); | |||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if ( defined $expires ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 144 | 0 | $resph{Expires} = time2str( round($expires) ); | |||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ( defined $changed ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 147 | 0 | $resph{LastModified} = time2str( round($changed) ); | |||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ( defined $etag ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if ($weak) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 151 | 0 | $resph{Etag} = 'W/"' . $etag . '"'; | |||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||
| 153 | else { | ||||||||||||||||||||||||||||||||||
| 154 | 0 | $resph{Etag} = '"' . $etag . '"'; | |||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if ( $get_or_head and !$dry ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$get_or_head and not $dry
MC/DC0%0/2
$get_or_head and not $dry
$get_or_head
not $dry
Truth table0%0/3
A and not(B)
A= $get_or_headB= not $dry
| |||||||||||||||||||||||||||||||||||
| 159 | 0 | $dsl->response->header( HTTP::Headers::Fancy::encode_hash(%resph) ); | |||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | unless ($check) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 163 | 0 | return $builder->(); | |||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | my $if_match = ( exists $reqh{IfMatch} and defined $reqh{IfMatch} ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
exists $reqh{'IfMatch'} && defined $reqh{'IfMatch'}
MC/DC0%0/2
exists $reqh{'IfMatch'} && defined $reqh{'IfMatch'}
exists $reqh{'IfMatch'}
defined $reqh{'IfMatch'}
Truth table0%0/3
A && B
A= exists $reqh{'IfMatch'}B= defined $reqh{'IfMatch'}
| |||||||||||||||||||||||||||||||||||
| 167 | my $if_match_any = | ||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | ( $if_match and ( $reqh{IfMatch} =~ qr{^ \s* \* \s* $}xsi ) ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$if_match && $reqh{'IfMatch'} =~ qr/^ \s* \* \s* $/six
MC/DC0%0/2
$if_match && $reqh{'IfMatch'} =~ qr/^ \s* \* \s* $/six
$if_match
$reqh{'IfMatch'} =~ qr/^ \s* \* \s* $/six
Truth table0%0/3
A && B
A= $if_matchB= $reqh{'IfMatch'} =~ qr/^ \s* \* \s* $/six
| |||||||||||||||||||||||||||||||||||
| 169 | my @if_match = | ||||||||||||||||||||||||||||||||||
| 170 | $if_match_any | ||||||||||||||||||||||||||||||||||
| 171 | ? () | ||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | : HTTP::Headers::Fancy::split_field_list( $reqh{IfMatch} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||
| 174 | my $if_none_match = | ||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | ( exists $reqh{IfNoneMatch} and defined $reqh{IfNoneMatch} ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
exists $reqh{'IfNoneMatch'} && defined $reqh{'IfNoneMatch'}
MC/DC0%0/2
exists $reqh{'IfNoneMatch'} && defined $reqh{'IfNoneMatch'}
exists $reqh{'IfNoneMatch'}
defined $reqh{'IfNoneMatch'}
Truth table0%0/3
A && B
A= exists $reqh{'IfNoneMatch'}B= defined $reqh{'IfNoneMatch'}
| |||||||||||||||||||||||||||||||||||
| 176 | my $if_none_match_any = | ||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | ( $if_none_match and ( $reqh{IfNoneMatch} =~ qr{^ \s* \* \s* $}xsi ) ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$if_none_match && $reqh{'IfNoneMatch'} =~ qr/^ \s* \* \s* $/six
MC/DC0%0/2
$if_none_match && $reqh{'IfNoneMatch'} =~ qr/^ \s* \* \s* $/six
$if_none_match
$reqh{'IfNoneMatch'} =~ qr/^ \s* \* \s* $/six
Truth table0%0/3
A && B
A= $if_none_matchB= $reqh{'IfNoneMatch'} =~ qr/^ \s* \* \s* $/six
| |||||||||||||||||||||||||||||||||||
| 178 | my @if_none_match = | ||||||||||||||||||||||||||||||||||
| 179 | $if_none_match_any | ||||||||||||||||||||||||||||||||||
| 180 | ? () | ||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | : HTTP::Headers::Fancy::split_field_list( $reqh{IfNoneMatch} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||
| 183 | 0 | my $if_modified_since = str2time( $reqh{IfModifiedSince} ); | |||||||||||||||||||||||||||||||||
| 184 | 0 | my $if_unmodified_since = str2time( $reqh{IfUnmodifiedSince} ); | |||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if ($if_match) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | my $xa = ( !!$if_match_any and !!$etag ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
!$if_match_any || !$etag
MC/DC0%0/2
!$if_match_any || !$etag
!$if_match_any
!$etag
Truth table0%0/3
not(A) || not(B)
A= !$if_match_anyB= !$etag
| |||||||||||||||||||||||||||||||||||
| 188 | 0 | my $xb = scalar grep { _cmp_weak( $etag, $_, $weak ) } @if_match; | |||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | unless ( $xa or $xb ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$xa or $xb
MC/DC0%0/2
$xa or $xb
$xa
$xb
Truth table0%0/3
A or B
A= $xaB= $xb
| |||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | HTTP::Exception->throw(412) if $throw; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | return 412 if $dry; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 192 | 0 | $dsl->send_error( 'Precondition Failed', 412 ); | |||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||
| 195 | ▶ | elsif ( $if_unmodified_since and defined $changed ) { | |||||||||||||||||||||||||||||||||
|
Condition0%0/3
$if_unmodified_since and defined $changed
MC/DC0%0/2
$if_unmodified_since and defined $changed
$if_unmodified_since
defined $changed
Truth table0%0/3
A and B
A= $if_unmodified_sinceB= defined $changed
| |||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | unless ( $if_unmodified_since > $changed ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | HTTP::Exception->throw(412) if $throw; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | return 412 if $dry; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 199 | 0 | $dsl->send_error( 'Precondition Failed', 412 ); | |||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ($if_none_match) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | my $xa = ( !!$if_none_match_any and !!$etag ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
!$if_none_match_any || !$etag
MC/DC0%0/2
!$if_none_match_any || !$etag
!$if_none_match_any
!$etag
Truth table0%0/3
not(A) || not(B)
A= !$if_none_match_anyB= !$etag
| |||||||||||||||||||||||||||||||||||
| 204 | 0 | my $xb = scalar grep { _cmp_weak( $etag, $_, $weak ) } @if_none_match; | |||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ( $xa or $xb ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$xa or $xb
MC/DC0%0/2
$xa or $xb
$xa
$xb
Truth table0%0/3
A or B
A= $xaB= $xb
| |||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if ($get_or_head) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | HTTP::Exception->throw(304) if $throw; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | return 304 if $dry; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 209 | 0 | $dsl->send_error( 'Not Modfied', 304 ); | |||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||
| 211 | else { | ||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | HTTP::Exception->throw(412) if $throw; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | return 412 if $dry; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 214 | 0 | $dsl->send_error( 'Precondition Failed', 412 ); | |||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||
| 218 | ▶ | elsif ( $get_or_head and $if_modified_since and defined $changed ) { | |||||||||||||||||||||||||||||||||
|
Condition0%0/6
$get_or_head and $if_modified_since and defined $changed
$get_or_head and $if_modified_since
MC/DC0%0/3
$get_or_head and $if_modified_since and defined $changed
$get_or_head
$if_modified_since
defined $changed
Truth table0%0/4
A and B and C
A= $get_or_headB= $if_modified_sinceC= defined $changed
| |||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if ( $if_modified_since > $changed ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | HTTP::Exception->throw(304) if $throw; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | return 304 if $dry; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 222 | 0 | $dsl->send_error( 'Not Modfied', 304 ); | |||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||
| 226 | 0 | return $builder->(); | |||||||||||||||||||||||||||||||||
| 227 | 3 | }; | |||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||
| 229 | 3 | register_plugin; | |||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||
| 231 | 3 | 1; | |||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||
| 233 | __END__ | ||||||||||||||||||||||||||||||||||