I don't know how to use $ua->credentials, but I've used the following method in the past:
use LWP::UserAgent; use HTTP::Request::Common; my $url = "http://www.domain.com/$filename"; my $ua = LWP::UserAgent->new(keep_alive=>1); my $headers = HTTP::Headers->new() $headers->authorization_basic('user', 'pass'); my $request = HTTP::Request(GET => $url, $headers); my $response = $ua->request($request); print "response:" . $response->code . "\n";
I think using $ua->credentials ends up sending two requests to the server (the first being answered with a 401), whereas the methods I presented gets it right the first time.
PS: Please put code in <code>..</code> tags in the future.
In reply to Re: LWP Credentials Login Problem to Download Zip Files
by ikegami
in thread LWP Credentials Login Problem to Download Zip Files
by noniekimp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |