Consider the following code:
use LWP;
$SIG{__DIE__} = \&myCode;
my $ua = LWP::UserAgent->new();
my $base = 'http://www.perl.com';
my $path = '/pub';
my $uri = URI->new_abs($path,$base);
my $req = HTTP::Request->new(GET => $uri);
my $res = $ua->request($req);
print $res->status_line,"\n";
sub myCode {
print "@_","\n";
}
When I run this I get the following from my DIE handler:
Missing base argument at
/usr/local/lib/perl5/site_perl/5.6.0/HTTP/Request.pm line 107
and then prints
200 OK
as expected.
The offending lines read like this:
# Argh!! Hate this... old LWP legacy!
eval { $uri = $uri->abs; };
die $@ if $@ && $@ !~ /Missing base argument/;
As far as I can tell $uri->abs should take an argument, shouldn't it?
Look in _generic.pm,
sub abs {
my $self = shift;
my $base = shift || Carp::croak("Missing base argument");
...
}
How about changing the eval to:
eval{ $uri = $uri->abs($uri->host) };
If I leave out the die handler you would never see this but
I shouldn't have too.
-Tim