Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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";

In reply to Re: HTTP::Request::Common Retry Option by Khen1950fx
in thread HTTP::Request::Common Retry Option by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (1)
As of 2023-01-28 17:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?