CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
wait time for LWP request

 



zatlas1
User

Dec 17, 2015, 7:12 AM

Post #1 of 5 (2390 views)
wait time for LWP request Can't Post

Scenario:
User called a restful web service that takes too long to complete, but this was not known in advance. The user wants to abandon the request if it was not completed in nnn seconds.

Is there a way to do it?

Thanks
ZA


Zhris
Enthusiast

Dec 17, 2015, 12:55 PM

Post #2 of 5 (2369 views)
Re: [zatlas1] wait time for LWP request [In reply to] Can't Post

If you're calling a remote web service, use a module such as LWP::UserAgent and its timeout attribute.

If a user is calling your webservice, look at your servers configuration documentation i.e. with Apache there is Timeout or even mod_reqtimeout.

Chris


zatlas1
User

Dec 17, 2015, 3:05 PM

Post #3 of 5 (2361 views)
Re: [Zhris] wait time for LWP request [In reply to] Can't Post

I looked for such an attribute (timeout) for LWP::UserAgent before I'd posted the question,and could not find it. I looked again and could not find it again. What is the exact name of the attribute?

Thank you
ZA


FishMonger
Veteran / Moderator

Dec 17, 2015, 5:18 PM

Post #4 of 5 (2352 views)
Re: [zatlas1] wait time for LWP request [In reply to] Can't Post


In Reply To
I looked for such an attribute (timeout) for LWP::UserAgent before I'd posted the question,and could not find it. I looked again and could not find it again. What is the exact name of the attribute?

Thank you
ZA


That's odd since it's shown in the synopsis.

Code
SYNOPSIS ^ 

require LWP::UserAgent;

my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;

my $response = $ua->get('http://search.cpan.org/');

if ($response->is_success) {
print $response->decoded_content; # or whatever
}
else {
die $response->status_line;
}


Did you read the synopsis?

It's also in the Constructor Methods. Did you read that?


(This post was edited by FishMonger on Dec 17, 2015, 5:23 PM)


zatlas1
User

Dec 17, 2015, 6:22 PM

Post #5 of 5 (2342 views)
Re: [FishMonger] wait time for LWP request [In reply to] Can't Post

It is very odd. I was sure that I looked at the correct page and did search for 'timeout'. I am not in the office now so I cannot retrace my missteps.

In any case, thank you. I now see how to do it.
Thank you.
ZA

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives