Skip to content

Commit

Permalink
In MetaCPAN::Web::Model::API::request, retry once if we get a connect…
Browse files Browse the repository at this point in the history
…ion timeout
  • Loading branch information
Clinton Gormley committed Sep 5, 2011
1 parent 2b29ccc commit 4cd3c06
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/MetaCPAN/Web/Model/API.pm
Expand Up @@ -39,7 +39,7 @@ sub model {
}

sub request {
my ( $self, $orig_path, $search, $params ) = @_;
my ( $self, $orig_path, $search, $params, $timed ) = @_;
my ( $token, $method ) = @$params{qw(token method)};
my $path = $orig_path;
$path .= "?access_token=$token" if ($token);
Expand All @@ -52,12 +52,15 @@ sub request {
persistent => 1,
sub {
my ( $data, $headers ) = @_;
if ( $headers->{Status} == 596
&& $headers->{Reason} eq 'Broken pipe' )
if ($headers->{Status} == 596
and ( $headers->{Reason} eq 'Broken pipe'
or $headers->{Reason} =~ /timed out/ and not $timed++ )
)
{
my $cv = $self->request( $orig_path, $search, $params );
my $cv = $self->request( $orig_path, $search, $params, $timed );
return $cv->cb( sub { $req->send( $cv->recv ) } );
}

my $content_type = $headers->{'content-type'} || '';

if ( $content_type =~ /^application\/json/ ) {
Expand Down

0 comments on commit 4cd3c06

Please sign in to comment.