in reply to LWP error 500 timeout

For example, a call to get:

#!/usr/bin/perl use strict; use warnings; use HTTP::Response; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $res = $ua->get('http://www.perlmonks.com'); if ($res->is_success){ print $res->decoded_content; } else { print "Error: " . $res->status_line . "\n"; }

Replies are listed 'Best First'.
Re^2: LWP error 500 timeout
by perlmonkdr (Beadle) on Feb 16, 2008 at 21:58 UTC

    Yes, thank for your reply, but note, that this method fail after some request and using the second way not, Why?

    #!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use LWP::Debug qw(+); BEGIN { close STDERR; open STDERR, '>./lwp-error.txt'; } END { close STDERR; } my $a=0; my $ua = LWP::UserAgent->new; # in some point this method fail. while (11000 > $a++) { my $res = $ua->get('http://www.perlmonks.com'); if ($res->is_success){ print $res->decoded_content; } else { print "Error: " . $res->status_line . "\n"; } }
      Phases of the moon.
Re^2: LWP error 500 timeout
by ambrus (Abbot) on Feb 18, 2008 at 08:49 UTC