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;
In reply to Re: LWP::Credentials help with previously working perl script PLEASE???
by tachyon-II
in thread LWP::Credentials help with previously working perl script PLEASE???
by funeeldy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |