LWP, timeouts and error handling

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I'm using the LWP::UserAgent and LWP::Parallel to make several HTTP
requests. I think that the settings of the different timeouts are hard
to understand and hard to trace/track.

When I think about it, I think there should be two types of timeouts:
connection timeout and content timeout. Is it possible to set the
timeout for these types of timeouts? I've tried the
LWP::Parallel::UserAgent->timeout function and the
LWP::Parallel::UserAgent->wait. Are these functions what I'm looking

I've tried to use both of the above mentioned methods together with a
timeout to figure out how they work.

First I tried to simulate a connection timeout with a timeout of 1
second. However, the $response->is_error function doesn't seem to work
to catch this error. (I'm using a callback function for my requests).
Am I doing something wrong here or should I use some other function to
track these errors? (and yes, the server that I tested on was down).

I've also tried to simulate a content timeout. But this doesn't seem to
work. I've put together a page that very slowly echos new content. When
requesting this page I expected the LWP component to abort the request
after 5 seconds according to my settings. However the whole page gets
loaded, and it took about 60 seconds. The $response->is_error seems to
be useless.

I also would like to know if the connection timeout is my fault (if my
own Internet connection is down) or if it's the requested server fault
(that server is down). Is it possible to figure this out?

Also, I would like to be able to limit the total size of content that a
single response should be able to send to me. Is this possible?

I've tried to read the docs. But I think that the information is
focusing on the good conditions of the http request, not the bad ones.
How to track errors is a important task.

Thanks for any input!


Site Timeline