summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorMainframe2008 <thg.bot@gmail.com>2013-01-30 20:32:50 +0100
committerMainframe2008 <thg.bot@gmail.com>2013-01-30 20:32:50 +0100
commit06063f56bb11f06593b114316f34f338fe50cfd0 (patch)
tree2dc4f66d74726c61985a22be7b2b898b9418632a /lib
parentUpdate lib/Net/Riak/Role/REST.pm (diff)
downloadnet-riak-06063f56bb11f06593b114316f34f338fe50cfd0.tar.gz
Update lib/Net/Riak/Role/UserAgent.pm
Added ssl/https functionality to useragent attribute
Diffstat (limited to 'lib')
-rw-r--r--lib/Net/Riak/Role/UserAgent.pm54
1 files changed, 49 insertions, 5 deletions
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 <franck@lumberjaph.net>, robin edwards <robin.ge@gmail.com>
+
+=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
+