develooper Front page | perl.libwww | Postings from April 2001

HTTP::Request DIE error

Thread Next
From:
Tim Allwine
Date:
April 11, 2001 15:04
Subject:
HTTP::Request DIE error
Message ID:
3AD4D4E5.BC5E56E0@oreilly.com
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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About