line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Headers::Auth; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
422
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '6.44'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use HTTP::Headers; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package |
11
|
|
|
|
|
|
|
HTTP::Headers; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
14
|
|
|
|
|
|
|
# we provide a new (and better) implementations below |
15
|
1
|
|
|
1
|
|
8
|
undef(&www_authenticate); |
16
|
1
|
|
|
|
|
573
|
undef(&proxy_authenticate); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require HTTP::Headers::Util; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _parse_authenticate |
22
|
|
|
|
|
|
|
{ |
23
|
4
|
|
|
4
|
|
6
|
my @ret; |
24
|
4
|
|
|
|
|
12
|
for (HTTP::Headers::Util::split_header_words(@_)) { |
25
|
9
|
100
|
|
|
|
21
|
if (!defined($_->[1])) { |
26
|
|
|
|
|
|
|
# this is a new auth scheme |
27
|
6
|
|
|
|
|
12
|
push(@ret, shift(@$_) => {}); |
28
|
6
|
|
|
|
|
9
|
shift @$_; |
29
|
|
|
|
|
|
|
} |
30
|
9
|
50
|
|
|
|
16
|
if (@ret) { |
31
|
|
|
|
|
|
|
# this a new parameter pair for the last auth scheme |
32
|
9
|
|
|
|
|
16
|
while (@$_) { |
33
|
6
|
|
|
|
|
9
|
my $k = shift @$_; |
34
|
6
|
|
|
|
|
9
|
my $v = shift @$_; |
35
|
6
|
|
|
|
|
17
|
$ret[-1]{$k} = $v; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
|
|
|
|
|
|
# something wrong, parameter pair without any scheme seen |
40
|
|
|
|
|
|
|
# IGNORE |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
4
|
|
|
|
|
21
|
@ret; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _authenticate |
47
|
|
|
|
|
|
|
{ |
48
|
8
|
|
|
8
|
|
11
|
my $self = shift; |
49
|
8
|
|
|
|
|
13
|
my $header = shift; |
50
|
8
|
|
|
|
|
26
|
my @old = $self->_header($header); |
51
|
8
|
100
|
|
|
|
20
|
if (@_) { |
52
|
6
|
|
|
|
|
17
|
$self->remove_header($header); |
53
|
6
|
|
|
|
|
15
|
my @new = @_; |
54
|
6
|
|
|
|
|
17
|
while (@new) { |
55
|
8
|
|
|
|
|
11
|
my $a_scheme = shift(@new); |
56
|
8
|
100
|
|
|
|
24
|
if ($a_scheme =~ /\s/) { |
57
|
|
|
|
|
|
|
# assume complete valid value, pass it through |
58
|
1
|
|
|
|
|
4
|
$self->push_header($header, $a_scheme); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
7
|
|
|
|
|
9
|
my @param; |
62
|
7
|
100
|
|
|
|
19
|
if (@new) { |
63
|
5
|
|
|
|
|
8
|
my $p = $new[0]; |
64
|
5
|
100
|
|
|
|
16
|
if (ref($p) eq "ARRAY") { |
|
|
100
|
|
|
|
|
|
65
|
1
|
|
|
|
|
3
|
@param = @$p; |
66
|
1
|
|
|
|
|
2
|
shift(@new); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
elsif (ref($p) eq "HASH") { |
69
|
3
|
|
|
|
|
9
|
@param = %$p; |
70
|
3
|
|
|
|
|
5
|
shift(@new); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
7
|
|
|
|
|
15
|
my $val = ucfirst(lc($a_scheme)); |
74
|
7
|
100
|
|
|
|
15
|
if (@param) { |
75
|
4
|
|
|
|
|
5
|
my $sep = " "; |
76
|
4
|
|
|
|
|
9
|
while (@param) { |
77
|
6
|
|
|
|
|
10
|
my $k = shift @param; |
78
|
6
|
|
|
|
|
9
|
my $v = shift @param; |
79
|
6
|
100
|
100
|
|
|
25
|
if ($v =~ /[^0-9a-zA-Z]/ || lc($k) eq "realm") { |
80
|
|
|
|
|
|
|
# must quote the value |
81
|
3
|
|
|
|
|
6
|
$v =~ s,([\\\"]),\\$1,g; |
82
|
3
|
|
|
|
|
8
|
$v = qq("$v"); |
83
|
|
|
|
|
|
|
} |
84
|
6
|
|
|
|
|
12
|
$val .= "$sep$k=$v"; |
85
|
6
|
|
|
|
|
15
|
$sep = ", "; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
7
|
|
|
|
|
15
|
$self->push_header($header, $val); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
8
|
100
|
|
|
|
22
|
return unless defined wantarray; |
93
|
5
|
100
|
|
|
|
19
|
wantarray ? _parse_authenticate(@old) : join(", ", @old); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
5
|
|
|
5
|
1
|
16
|
sub www_authenticate { shift->_authenticate("WWW-Authenticate", @_) } |
98
|
3
|
|
|
3
|
1
|
7
|
sub proxy_authenticate { shift->_authenticate("Proxy-Authenticate", @_) } |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |