Adam Newby <[EMAIL PROTECTED]> writes:
> We've written a script that makes a request using LWP::UserAgent, using
> the 'callback' method to process the response in chunks. In the script, we
> also modified the default __DIE__ handler to output an HTML-formatted
> error message.
Using __DIE__ handlers is evil. You should not do that :) It would be
better to wrap your script in an eval{} and by that trapping
exceptions the proper way.
> Pointing it at http://news.ino.com/intraday/?storyid=DJN2002020114150001
> results in a non-fatal error being generated in HTTP::Cookies::_url_path,
> at line 659:
>
> my $path = eval { $url->epath }; # URI::URL method
> $path = $url->path if $@; # URI::_generic method
>
> ...because of the eval.
The normal fix in these situations is to make it:
eval {
local $SIG{__DIE__};
...
};
but your way of fixing seems better in this case.
> In our script, this resulted in the HTML-formatted
> error being outputted, followed by the page itself. To avoid the error
> message, I've changed the code to read:
>
> my $path;
> if($url->can('epath')) {
> $path = $url->epath; # URI::URL method
> } else {
> $path = $url->path; # URI::_generic method
> }
>
> ...which stops the error. NB this error doesn't happen with HTTP::Cookies
> v 1.16.
>
> A patch is below.
I have now applied this patch. Thanks!
Regards,
Gisle
> *** Cookies.pm Fri Feb 1 16:47:37 2002
> --- Cookies.pm-2002-02-01 Fri Feb 1 16:45:31 2002
> ***************
> *** 656,667 ****
> sub _url_path
> {
> my $url = shift;
> ! my $path;
> ! if($url->can('epath')) {
> ! $path = $url->epath; # URI::URL method
> ! } else {
> ! $path = $url->path; # URI::_generic method
> ! }
> $path = "/" unless length $path;
> $path;
> }
> --- 656,663 ----
> sub _url_path
> {
> my $url = shift;
> ! my $path = eval { $url->epath }; # URI::URL method
> ! $path = $url->path if $@; # URI::_generic method
> $path = "/" unless length $path;
> $path;
> }