develooper Front page | perl.libwww | Postings from November 2002

Re: URI Bug?

Thread Previous | Thread Next
From:
Hans de Graaff
Date:
November 23, 2002 09:41
Subject:
Re: URI Bug?
Message ID:
87lm3kqj42.fsf@graaff.xs4all.nl
Hmm, it seems my post got corrupted somehow. Here's what I wrote:


On Thu, 21 Nov 2002, Darby Cacdac wrote:

> Im using the URI (1.22) module and I'm getting the error:
>=20
> "Can't locate object method "host" via package "URI::_generic"
> (perhaps you forgot to load "URI::_generic"?) at
> /usr/perl5/site_perl/5.6.1/URI/WithBase.pm line 50."
>=20
> It turns out that this error comes up when I'm doing a $url->host on
> a link that looks like this: <a href=3D"httpthrds/index.html">. As
> long as the link starts with http* (aside from http://*) the error
> is triggered.

I think the problem is that host() is only supported for those schemes
that have an authority component (see perldoc URI for more
details). It would be nice if there would be a simple test to
determine which schemes qualify for this. Currently I have this
hardcoded in my application to do this:=20

    $url->host(ip_address($url->host)) if $url->scheme =3D~ /^(https?|ftp|g=
opher|https|ldap|news|nntp|pop|rlogin|snews|telnet)$/;

I'd be happy to learn of a better way to do this, and I'm sure my list
is not complete anyway. I don't track new schemes being added, and
this may vary from installation to installation anyway.

Hans


Thread Previous | 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