| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTTP::Headers::ETag; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1266
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
732
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '6.43'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require HTTP::Date; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require HTTP::Headers; |
|
11
|
|
|
|
|
|
|
package |
|
12
|
|
|
|
|
|
|
HTTP::Headers; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _etags |
|
15
|
|
|
|
|
|
|
{ |
|
16
|
14
|
|
|
14
|
|
18
|
my $self = shift; |
|
17
|
14
|
|
|
|
|
22
|
my $header = shift; |
|
18
|
14
|
|
|
|
|
31
|
my @old = _split_etag_list($self->_header($header)); |
|
19
|
14
|
100
|
|
|
|
30
|
if (@_) { |
|
20
|
8
|
|
|
|
|
18
|
$self->_header($header => join(", ", _split_etag_list(@_))); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
14
|
100
|
|
|
|
92
|
wantarray ? @old : join(", ", @old); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
11
|
|
|
11
|
0
|
651
|
sub etag { shift->_etags("ETag", @_); } |
|
26
|
1
|
|
|
1
|
0
|
4
|
sub if_match { shift->_etags("If-Match", @_); } |
|
27
|
1
|
|
|
1
|
0
|
3
|
sub if_none_match { shift->_etags("If-None-Match", @_); } |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub if_range { |
|
30
|
|
|
|
|
|
|
# Either a date or an entity-tag |
|
31
|
7
|
|
|
7
|
0
|
1081
|
my $self = shift; |
|
32
|
7
|
|
|
|
|
16
|
my @old = $self->_header("If-Range"); |
|
33
|
7
|
100
|
|
|
|
17
|
if (@_) { |
|
34
|
3
|
|
|
|
|
6
|
my $new = shift; |
|
35
|
3
|
100
|
|
|
|
13
|
if (!defined $new) { |
|
|
|
100
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
4
|
$self->remove_header("If-Range"); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
elsif ($new =~ /^\d+$/) { |
|
39
|
1
|
|
|
|
|
4
|
$self->_date_header("If-Range", $new); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
else { |
|
42
|
1
|
|
|
|
|
3
|
$self->_etags("If-Range", $new); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
7
|
100
|
|
|
|
41
|
return unless defined(wantarray); |
|
46
|
4
|
|
|
|
|
8
|
for (@old) { |
|
47
|
3
|
|
|
|
|
8
|
my $t = HTTP::Date::str2time($_); |
|
48
|
3
|
100
|
|
|
|
145
|
$_ = $t if $t; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
4
|
100
|
|
|
|
30
|
wantarray ? @old : join(", ", @old); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Split a list of entity tag values. The return value is a list |
|
55
|
|
|
|
|
|
|
# consisting of one element per entity tag. Suitable for parsing |
|
56
|
|
|
|
|
|
|
# headers like C, C. You might even want to |
|
57
|
|
|
|
|
|
|
# use it on C and C entity tag values, because it will |
|
58
|
|
|
|
|
|
|
# normalize them to the common form. |
|
59
|
|
|
|
|
|
|
# |
|
60
|
|
|
|
|
|
|
# entity-tag = [ weak ] opaque-tag |
|
61
|
|
|
|
|
|
|
# weak = "W/" |
|
62
|
|
|
|
|
|
|
# opaque-tag = quoted-string |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _split_etag_list |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
22
|
|
|
22
|
|
41
|
my(@val) = @_; |
|
68
|
22
|
|
|
|
|
27
|
my @res; |
|
69
|
22
|
|
|
|
|
38
|
for (@val) { |
|
70
|
19
|
|
|
|
|
33
|
while (length) { |
|
71
|
29
|
|
|
|
|
40
|
my $weak = ""; |
|
72
|
29
|
100
|
|
|
|
91
|
$weak = "W/" if s,^\s*[wW]/,,; |
|
73
|
29
|
|
|
|
|
43
|
my $etag = ""; |
|
74
|
29
|
100
|
66
|
|
|
140
|
if (s/^\s*(\"[^\"\\]*(?:\\.[^\"\\]*)*\")//) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
75
|
13
|
|
|
|
|
50
|
push(@res, "$weak$1"); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
elsif (s/^\s*,//) { |
|
78
|
6
|
100
|
|
|
|
19
|
push(@res, qq(W/"")) if $weak; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
elsif (s/^\s*([^,\s]+)//) { |
|
81
|
8
|
|
|
|
|
17
|
$etag = $1; |
|
82
|
8
|
|
|
|
|
14
|
$etag =~ s/([\"\\])/\\$1/g; |
|
83
|
8
|
|
|
|
|
27
|
push(@res, qq($weak"$etag")); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
elsif (s/^\s+// || !length) { |
|
86
|
2
|
100
|
|
|
|
7
|
push(@res, qq(W/"")) if $weak; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
else { |
|
89
|
0
|
|
|
|
|
0
|
die "This should not happen: '$_'"; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} |
|
93
|
22
|
|
|
|
|
65
|
@res; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |