in reply to LWP::Credentials help with previously working perl script PLEASE???
This code works.
use LWP::UserAgent; my $url = "http://prism.library.cornell.edu/control/authBasic/authTest +/"; my ($servername) = $url =~ m!://([^/]+)!; my $port = 80; my $realm = 'User: test Pass:'; my $username = 'test'; my $password = 'this'; my $lwp = LWP::UserAgent->new( ); $lwp->cookie_jar( {} ); $lwp->credentials("$servername:$port", $realm, $username, $password); my $response = $lwp->get($url); print $response->as_string;
In your code you have:
my $url="$url"; my $req = $browser->get($url); <--- response object, not request obje +ct $req->authorization_basic($username, $password); <--- here is where yo +u pass your response object <--- generating the e +rror..... my $res = $browser->request($req); print $res->as_string;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: LWP::Credentials help with previously working perl script PLEASE???
by funeeldy (Initiate) on May 19, 2008 at 14:15 UTC | |
by tachyon-II (Chaplain) on May 19, 2008 at 15:40 UTC |