summary refs log tree commit diff
path: root/lib/Net/Riak
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Net/Riak')
-rw-r--r--lib/Net/Riak/Role/REST.pm39
-rw-r--r--lib/Net/Riak/Role/UserAgent.pm54
2 files changed, 87 insertions, 6 deletions
diff --git a/lib/Net/Riak/Role/REST.pm b/lib/Net/Riak/Role/REST.pm
index 261d573..92ea3ae 100644
--- a/lib/Net/Riak/Role/REST.pm
+++ b/lib/Net/Riak/Role/REST.pm
@@ -1,4 +1,7 @@
 package Net::Riak::Role::REST;
+{
+  $Net::Riak::Role::REST::VERSION = '0.1600';
+}
 
 # ABSTRACT: role for REST operations
 
@@ -8,6 +11,7 @@ use Moose::Role;
 use MooseX::Types::Moose 'Bool';
 use Net::Riak::Types qw/HTTPResponse HTTPRequest/;
 use Data::Dump 'pp';
+use Data::Dumper;
 with qw/Net::Riak::Role::REST::Bucket 
     Net::Riak::Role::REST::Object 
     Net::Riak::Role::REST::Link
@@ -35,6 +39,12 @@ has disable_return_body => (
     default => 0
 );
 
+has ssl => (
+    is => 'rw',
+	isa => Bool,
+	default => 0
+);
+
 sub _build_path {
     my ($self, $path) = @_;
     $path = join('/', @$path);
@@ -44,6 +54,7 @@ sub _build_uri {
     my ($self, $path, $params) = @_;
 
     my $uri = URI->new($self->get_host);
+    if ( $uri =~ /^https:.+/ ) { $self->ssl(1); }
     $uri->path($self->_build_path($path));
     $uri->query_form(%$params);
     $uri;
@@ -61,8 +72,9 @@ sub send_request {
     my ($self, $req) = @_;
 
     $self->http_request($req);
+    
     my $r = $self->useragent->request($req);
-
+	
     $self->http_response($r);
 
     if ($ENV{RIAK_VERBOSE}) {
@@ -99,3 +111,28 @@ sub stats {
 }
 
 1;
+
+__END__
+=pod
+
+=head1 NAME
+
+Net::Riak::Role::REST - role for REST operations
+
+=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
+
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
+