Reinier Post <[EMAIL PROTECTED]> writes:

> I use the following local patch to LWP::RobotUA :
> 
> % perldoc -m LWP::RobotUA.pm | diff - lib/LWP/RobotUA.pm
> 1c1
> < # $Id: RobotUA.pm,v 1.17 2000/04/09 11:21:11 gisle Exp $
> ---
> > # $Id: RobotUA.pm,v 1.171 2000/08/09 11:25:23 cvs Exp $
> 7c7
> < $VERSION = sprintf("%d.%02d", q$Revision: 1.17 $ =~ /(\d+)\.(\d+)/);
> ---
> > $VERSION = sprintf("%d.%02d", q$Revision: 1.171 $ =~ /(\d+)\.(\d+)/);
> 234c234,235
> <     my $netloc = $request->url->host_port;
> ---
> >     my $ru = $request->url;
> >     my $netloc = $ru->can('host_port') ? $ru->host_port : $ru->host;

Not all URIs have a 'host' method either.  I think simply making it:

   $netloc = eval { $ru->host_port };

should do.

But then we have the $SIG{__DIE__} stupidity which makes it:

   $netloc = eval { local $SIG{__DIE__}; $ru->host_port };

Regards,
Gisle


> Not all URIs actually have a host_port method defined, and this would
> cause my (also modified) WWW::Robot to crash.  However, can() is a
> fairly new Perl feature.  I don't think RobotUA should fail on things
> like this.
> 
>  + Is there a better way to address this?
>  + Would it be possible to incorporate this into the standard version?
>    I hate having to drag my own patches around ...
> 
> -- 
> Reinier

Reply via email to