blob: c736f0a30617b6a405306e53b07dfb5b3dcc2d8a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
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;
sub connection_cache { $CONN_CACHE ||= LWP::ConnCache->new }
has ua_timeout => (
is => 'rw',
isa => 'Int',
default => 120
);
has ssl_opts => (
is => 'rw',
isa => 'HashRef'
);
has useragent => (
is => 'rw',
isa => 'LWP::UserAgent',
lazy => 1,
default => sub {
my $self = shift;
# The Links header Riak returns (esp. for buckets) can get really long,
# so here increase the MaxLineLength LWP will accept (default = 8192)
my %opts = @LWP::Protocol::http::EXTRA_SOCK_OPTS;
$opts{MaxLineLength} = 65_536;
@LWP::Protocol::http::EXTRA_SOCK_OPTS = %opts;
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);
$ua;
}
);
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
|