develooper Front page | perl.libwww | Postings from January 2001

Can't call method "request" on an undefined value at ...

Vern Hart
January 28, 2001 23:51
Can't call method "request" on an undefined value at ...
Message ID:
Full error:

    Can't call method "request" on an undefined value at
    /usr/lib/perl5/site_perl/5.005/LWP/ line 227, <DOM>
    chunk 69.

I've got a script that does a couple thousand requests to an https
URL.  I get the above error sporadicly.  I've had it at chunk 69,
640, 234, etc.  It's seemingly random and nothing changes between
runs except the location of the error.

I'm new to the list but noticed, in the archive, someone having a
similar (but more repeatable) problem.
One similarity is that Robert was using the same protocol, https.

The problem within LWP::UserAgent::simple_request (which gets called
from LWP::UserAgent::request, which I'm using) is that the eval
block at line 211 dies but $@ is not set to anything.  I worked
around the problem by creating a valid response object if $response
was not defined just after the eval block.

It's possible there's a bug in LWP::Protocol::https (since both
Robert and I are using https) but I can't reproduced the error
reliably enough to track it there.

The following patch is probably not a long-term solution but it at
least gives an error response instead of crashing the script.  In my
case, my script handles the false $response->is_success and retries
the request which then works.  YMMV.


--- LWP/UserAgent.old	Thu Jun  1 07:35:15 2000
+++ LWP/	Sun Jan 28 23:26:26 2001
@@ -218,6 +218,12 @@
+	elsif (!defined $response)
+	{
+	    $response =
+	      HTTP::Response->new(&HTTP::Status::RC_INTERNAL_SERVER_ERROR,
+				  "Unknown Error");
+	}
     } else {
	$response = $protocol->request($request, $proxy,
				       $arg, $size, $timeout); Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About