AWS-SQS-Simple

 view release on metacpan or  search on metacpan

lib/AWS/SQS/Simple.pm  view on Meta::CPAN

        my $value_octets = encode('utf-8-strict', $params->{ $key } ) ;

        $to_sign .= escape( $key_octets ) . '=' . escape( $value_octets ) ;

    }
    
    return $to_sign ;
}


=head2 escape 

    URI escape only the characters that should be escaped, according to RFC 3986

=cut

sub escape {

    my ($str) = @_;

    return uri_escape_utf8( $str,'^A-Za-z0-9\-_.~' ) ;
}

=head2 _generate_timestamp 

 Calculate current TimeStamp 

=cut 

sub _generate_timestamp {

    return sprintf("%04d-%02d-%02dT%02d:%02d:%02d.000Z",
                   sub { ($_[5]+1900,
                          $_[4]+1,
                          $_[3],
                          $_[2],
                          $_[1],
                          $_[0])
                   }->(gmtime(time)));
}

=head2 _make_request 

=cut

sub _make_request {

    my $self          = shift ;
    my $url_to_access = shift ;

    my $contents                             ;
    my $attempts = 0                         ;
    my $got_data = 0                         ;
    
    my $this_profile_location                ;
    
    my $response;
    
    until( $got_data or $attempts > 5 ) { 
	
	my $request = HTTP::Request->new(
	    GET => $url_to_access
	    );
	
	my $ua = LWP::UserAgent->new             ;
	$ua->timeout(60)                         ;
	$ua->env_proxy                           ;
	$ua->agent( 'AWIS-INFO_GET/'.$VERSION ) ;
	
	$response = $ua->request( $request )  ;

	if( $response->is_success() ) {
	    
	    $contents = $response->content;
	    $got_data = 1;
	    
	} else  {

	    $contents = $response->content          ;
	    
	    print STDERR "ERROR : $contents"        ;  

	    $attempts++             ;
	    sleep( $attempts * 10 ) ;
	    
	}
	
	$contents = $response->content          ;
	
	$attempts++                             ;
	
    }
    

    my $response_content = $response->content     ;

    return $response_content                      ;

}


=head1 AUTHOR

Ankita, C<< <sankita.11 at gmail.com> >>


=head1 COPYRIGHT & LICENSE

Copyright 2014 Ankita Singhal, all rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

=cut

1; # End of AWS::SQS::Simple



( run in 1.002 second using v1.01-cache-2.11-cpan-39bf76dae61 )