I'm not an expert, but I believe the username and password aren't sent
except to answer a 401 or 407 response from the server.

The realm you give in credentials() has to match the WWW-Authenticate header
included in the 401 response or the Proxy-Authenticate header in a 407
response.  Try fetching the page with lwp-request (without using the -C
option) to see what realm is given by the site.

Look for 'authenticate' and 'authorization' in the output from 'perldoc
HTTP::Headers'.  'ACCESS TO PROTECTED DOCUMENTS' in lwpcook.pod might also
help.

--
Mac :})
----- Original Message -----
From: Aaron Turner <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 29, 2000 0:38
Subject: Getting documents that are protected by basic auth


> I'm going nuts.  I've read all the online docs, and found some books, but
> for the life of me I can't get a password protected doc.  I put a sniffer
> on the link, and found that the script isn't even sending the auth info to
> the server at all.  Here's the code which tries to print out the page:
>
> #!/usr/bin/perl
> use LWP::UserAgent;
> use HTTP::Request;
> use HTTP::Response;
> use strict;
> my $passwd = 'myname';
> my $uname = 'mypass';
> my $domain = 'My Realm Name';
> my $agent = 'linuxkb-modperl';
> my $url = 'http://devel.linuxkb.org/todo.html';
>
> my $ua = LWP::UserAgent->new();
> $ua->agent($agent);
> $ua->credentials($url, $domain, $uname, $passwd);
>
> my $request = HTTP::Request->new(GET => $url);
> $request->referer("http://localhost/");
>
> my $response = $ua->request($request);
> print $response->content;
>
> What is wrong???  Why will it send the referrer and agent info, but not
> the http-auth info?

Reply via email to