in reply to LWP Credentials Login Problem to Download Zip Files
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: LWP Credentials Login Problem to Download Zip Files
by noniekimp (Sexton) on Sep 01, 2004 at 18:11 UTC | |
|
Re^2: LWP Credentials Login Problem to Download Zip Files
by noniekimp (Sexton) on Aug 26, 2004 at 16:30 UTC | |
by ikegami (Patriarch) on Aug 26, 2004 at 16:40 UTC | |
|
Re^2: LWP Credentials Login Problem to Download Zip Files
by OfficeLinebacker (Chaplain) on Oct 30, 2013 at 00:27 UTC | |
|
Re^2: LWP Credentials Login Problem to Download Zip Files
by noniekimp (Sexton) on Aug 26, 2004 at 16:40 UTC | |
by ikegami (Patriarch) on Aug 26, 2004 at 16:45 UTC | |
by noniekimp (Sexton) on Sep 01, 2004 at 18:04 UTC |