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

Re: URI Bug?

Thread Previous | Thread Next
From:
Darby Cacdac
Date:
November 23, 2002 10:39
Subject:
Re: URI Bug?
Message ID:
3DDE88FF.5020802@sun.com
Lemme give you a code sample:

#!/usr/bin/perl

use URI::URL;
$attr_value = "products/index.html";  # This is a valid relative link!
$url = url $attr_value;
$host = $url->host;

Running the above code generates the error below. In my mind it 
shouldn't produce an error because $attr_value is a valid url (even if 
it doen't have the host element explicitly included). In the above case, 
I'm expecting   $url->host to return null or undefined but not a lousy 
error message!

If you were to change the $url->host line above to  to $url->scheme or 
$url->frag, no errors are generated  so why generate and error when you 
try to get the host portion? There has to be consistency.

The issue really here is not about and invalid scheme or URL. It is 
about providing consistent behavior in the URI::URL class interface.


Thurn, Martin wrote:

>>"Can't locate object method "host" via package 
>>"URI::_generic" (perhaps you forgot to load "URI::_generic"?) 
>>    
>>
>
>That's the error you get whenever you try to create a URI with a scheme that
>it doesn't know about.  You should either check the scheme yourself, or wrap
>the 'new URI' in an eval.
>
>Perl & LWP book
>http://www.amazon.com/exec/obidos/ASIN/0596001789/thestarwarscol06
>
>--
> - - Martin 'Kingpin' Thurn 
>
>  
>

-- 
-----------------------------+o0o+-----------------------------
Darby Cacdac                    Sun Microsystems, Inc.
TE - Advance Engineering        901 San Antonio Road, USJC06-203
eMail:  darby.cacdac@sun.com    Palo Alto, California  94303
  Tel:  (408) 635-0808          http://www.sun.com





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