File Coverage

blib/lib/REST/Neo4p/Agent/LWP/UserAgent.pm
Criterion Covered Total %
statement 22 28 78.5
branch 0 2 0.0
condition 0 3 0.0
subroutine 7 10 70.0
pod 2 4 50.0
total 31 47 65.9


line stmt bran cond sub pod time code
1             #$Id$
2             package REST::Neo4p::Agent::LWP::UserAgent;
3 4     4   27 use base qw/LWP::UserAgent REST::Neo4p::Agent/;
  4         11  
  4         947  
4 4     4   2008 use LWP::Authen::Basic;
  4         68723  
  4         198  
5 4     4   1831 use LWP::ConnCache;
  4         4778  
  4         124  
6 4     4   26 use strict;
  4         8  
  4         88  
7 4     4   20 use warnings;
  4         10  
  4         154  
8             BEGIN {
9 4     4   784 $REST::Neo4p::Agent::LWP::UserAgent::VERSION = '0.4000';
10             }
11             sub new {
12 4     4 1 11 my ($class,@args) = @_;
13 4         87 my $self = $class->SUPER::new(@_);
14             #This really helps server not to be blown by TIME_WAIT'ed sockets.
15             #If load is high - even if 1 thread is used -
16             #with disabled keep-alive sockets are screwed on the server side.
17 4         12514 my $cache = LWP::ConnCache->new;
18             #TODO FIXME This number should be configurable in some comfortable way
19 4         208 $cache->total_capacity([30]);
20 4         139 $self->conn_cache($cache);
21 4         83 return $self;
22             }
23 0     0 0   sub add_header { shift->default_headers->header(@_) }
24 0     0 0   sub remove_header { shift->default_headers->remove_header($_[0]) }
25             sub credentials {
26 0     0 1   my $self = shift;
27 0           my ($host, $realm, $user, $pass) = @_;
28 0 0 0       if ($user && $pass) {
29 0           $self->default_header(
30             Authorization => LWP::Authen::Basic->auth_header($user, $pass)
31             );
32             }
33             }
34             1;