4 use HTTP::Headers::Auth;
6 $res = HTTP::Response->new(401);
7 $res->push_header(WWW_Authenticate => qq(Foo realm="WallyWorld", foo=bar, Bar realm="WallyWorld2"));
8 $res->push_header(WWW_Authenticate => qq(Basic Realm="WallyWorld", foo=bar, bar=baz));
10 print $res->as_string;
12 %auth = $res->www_authenticate;
14 print "not " unless keys(%auth) == 3;
17 print "not " unless $auth{basic}{realm} eq "WallyWorld" &&
18 $auth{bar}{realm} eq "WallyWorld2";
21 $a = $res->www_authenticate;
22 print "not " unless $a eq 'Foo realm="WallyWorld", foo=bar, Bar realm="WallyWorld2", Basic Realm="WallyWorld", foo=bar, bar=baz';
25 $res->www_authenticate("Basic realm=foo1");
26 print $res->as_string;
28 $res->www_authenticate(Basic => {realm => foo2});
29 print $res->as_string;
31 $res->www_authenticate(Basic => [realm => foo3, foo=>33],
32 Digest => {nonce=>"bar", foo=>'foo'});
33 print $res->as_string;
37 print "not " unless /WWW-Authenticate: Basic realm="foo3", foo=33/ &&
38 (/WWW-Authenticate: Digest nonce=bar, foo=foo/ ||
39 /WWW-Authenticate: Digest foo=foo, nonce=bar/);