From 06063f56bb11f06593b114316f34f338fe50cfd0 Mon Sep 17 00:00:00 2001 From: Mainframe2008 Date: Wed, 30 Jan 2013 20:32:50 +0100 Subject: Update lib/Net/Riak/Role/UserAgent.pm Added ssl/https functionality to useragent attribute --- lib/Net/Riak/Role/UserAgent.pm | 54 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/Net/Riak/Role/UserAgent.pm b/lib/Net/Riak/Role/UserAgent.pm index 9dacf96..c736f0a 100644 --- a/lib/Net/Riak/Role/UserAgent.pm +++ b/lib/Net/Riak/Role/UserAgent.pm @@ -1,10 +1,15 @@ package Net::Riak::Role::UserAgent; +{ + $Net::Riak::Role::UserAgent::VERSION = '0.1600'; +} # ABSTRACT: useragent for Net::Riak use Moose::Role; use LWP::UserAgent; use LWP::ConnCache; +use IO::Socket::SSL; +use Data::Dumper; our $CONN_CACHE; @@ -16,6 +21,11 @@ has ua_timeout => ( default => 120 ); +has ssl_opts => ( + is => 'rw', + isa => 'HashRef' +); + has useragent => ( is => 'rw', isa => 'LWP::UserAgent', @@ -28,11 +38,20 @@ has useragent => ( my %opts = @LWP::Protocol::http::EXTRA_SOCK_OPTS; $opts{MaxLineLength} = 65_536; @LWP::Protocol::http::EXTRA_SOCK_OPTS = %opts; - - my $ua = LWP::UserAgent->new( - timeout => $self->ua_timeout, - keep_alive => 1, - ); + my $ua = undef; + + if ( !$self->ssl ) { + $ua = LWP::UserAgent->new( + timeout => $self->ua_timeout, + keep_alive => 1, + ); + } else { + $ua = LWP::UserAgent->new( + timeout => $self->ua_timeout, + keep_alive => 1, + ssl_opts => $self->ssl_opts + ); + } $ua->conn_cache(__PACKAGE__->connection_cache); @@ -41,3 +60,28 @@ has useragent => ( ); 1; + +__END__ +=pod + +=head1 NAME + +Net::Riak::Role::UserAgent - useragent for Net::Riak + +=head1 VERSION + +version 0.1600 + +=head1 AUTHOR + +franck cuny , robin edwards + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2011 by linkfluence. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut + -- cgit 1.4.1