Parse::WWWAuthenticate - Parse the WWW-Authenticate HTTP header
version 0.04
use Parse::WWWAuthenticate qw(parse_wwwa); my $header = 'Basic realm="test"'; my @challenges = parse_wwwa( $header ); for my $challenge ( @challenges ) { print "Server accepts: " . $challenge->{name}; }
kinda more real life:
use LWP::UserAgent; use Parse::WWWAuthenticate qw(parse_wwwa); my $ua = LWP::UserAgent->new; my $response = $ua->get('http://some.domain.example'); my $header = $response->header('WWW-Authenticate'); my @challenges = parse_wwwa( $header ); for my $challenge ( @challenges ) { print "Try to use $challenge->{name}...\n"; }
parses the content of the WWW-Authenticate header and returns a hash of all the challenges and their data.
my $header = 'Basic realm="test"'; my @challenges = parse_wwwa( $header ); for my $challenge ( @challenges ) { print "Try to use $challenge->{name}...\n"; }
The testcases were generated with the httpauth.xml file from https://greenbyte.de/tech/tc/httpauth.
Renee Baecker <reneeb@cpan.org>
This software is Copyright (c) 2016 by Renee Baecker.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Parse::WWWAuthenticate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::WWWAuthenticate
CPAN shell
perl -MCPAN -e shell install Parse::WWWAuthenticate
For more information on module installation, please visit the detailed CPAN module installation guide.