bug in URI-1.04

Vlad Safronov (vlads@comptek.ru)
Wed, 08 Dec 1999 13:15:13 +0300


Hi !

Try the code below and you'll get a bug (latest LWP & URI installed):

Can't locate object method "host" via package "URI::_generic" at
/usr/local/lib/perl5/site_perl/5.005/URI/WithBase.pm line 41.

it's happened because of field in server response (HTTP header):

Content-Location: index.html

=== the code ===

#!/usr/local/bin/perl -w
# to: gisle@aas.no

use URI; # URI-1.04
use LWP::UserAgent;

my $ua = create_useragent();

my $request = new HTTP::Request('GET', 'http://www.iis.ru/');
my $response = $ua->request( $request );
if ($response->is_success) {
    my $uri = $response->base;
    print "real: " , $uri->as_string , "\n"; # will print "index.html"
    print "host: " , $uri->host() , "\n";
}
exit 0;

sub create_useragent()
{
    my $ua;

    $ua = new LWP::UserAgent;
    # Set useragent parameters :
    $ua->agent("Addurl/2.0");
    # Set timeout to 60 seconds
    $ua->timeout(60);

    return $ua;
}

===

Best regards,
******************************************************
Vlad A. Safronov         vlads@comptek.ru