X-Git-Url: http://git.maemo.org/git/?p=dh-make-perl;a=blobdiff_plain;f=dev%2Farm%2Flibwww-perl%2Flibwww-perl-5.813%2Flib%2FLWP%2FAuthen%2FBasic.pm;fp=dev%2Farm%2Flibwww-perl%2Flibwww-perl-5.813%2Flib%2FLWP%2FAuthen%2FBasic.pm;h=f4c5f4982bed0c236e30b1be45a392aba6b1ca50;hp=0000000000000000000000000000000000000000;hb=f477fa73365d491991707e7ed9217b48d6994551;hpb=da95c414033799c3a62606f299c3c00b5c77ca11 diff --git a/dev/arm/libwww-perl/libwww-perl-5.813/lib/LWP/Authen/Basic.pm b/dev/arm/libwww-perl/libwww-perl-5.813/lib/LWP/Authen/Basic.pm new file mode 100644 index 0000000..f4c5f49 --- /dev/null +++ b/dev/arm/libwww-perl/libwww-perl-5.813/lib/LWP/Authen/Basic.pm @@ -0,0 +1,36 @@ +package LWP::Authen::Basic; +use strict; + +require MIME::Base64; + +sub authenticate +{ + my($class, $ua, $proxy, $auth_param, $response, + $request, $arg, $size) = @_; + + my($user, $pass) = $ua->get_basic_credentials($auth_param->{realm}, + $request->url, $proxy); + return $response unless defined $user and defined $pass; + + my $auth_header = $proxy ? "Proxy-Authorization" : "Authorization"; + my $auth_value = "Basic " . MIME::Base64::encode("$user:$pass", ""); + + # Need to check this isn't a repeated fail! + my $r = $response; + while ($r) { + my $auth = $r->request->header($auth_header); + if ($auth && $auth eq $auth_value) { + # here we know this failed before + $response->header("Client-Warning" => + "Credentials for '$user' failed before"); + return $response; + } + $r = $r->previous; + } + + my $referral = $request->clone; + $referral->header($auth_header => $auth_value); + return $ua->request($referral, $arg, $size, $response); +} + +1;