http://qs321.pair.com?node_id=860581


in reply to HTTP::Request::Common Retry Option

You can control the number of retries by using LWP::UserAgent::Determined. I set the timing string at 5 seconds, 10, and 20. I also added the codes that I wanted it to retry.
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent::Determined; my $url = 'http://www.google.com'; my $browser = LWP::UserAgent::Determined->new( cookie_jar => '' ); my $timing_string = $browser->timing("5,10,20"); my $http_codes_hr = $browser->codes_to_determinate(); $http_codes_hr->{408} = 1; $http_codes_hr->{500} = 1; $http_codes_hr->{567} = 1; $browser->before_determined_callback( sub { print "Trying ", $_[4][0]->uri, " at ", scalar(localtime), "...\n"; }); $browser->after_determined_callback( sub { print "Just tried ", $_[4][0]->uri, " at ", scalar(localtime), ".\n"; }); my $response = $browser->get( $url ); print "That gave: ",$response->status_line, "\n";

Replies are listed 'Best First'.
Re^2: HTTP::Request::Common Retry Option
by bichonfrise74 (Vicar) on Sep 20, 2010 at 23:54 UTC
    I was just about to ask a question along these lines. Good thing somebody beat me to it.