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   35 use base qw/LWP::UserAgent REST::Neo4p::Agent/;
  4         35  
  4         3494  
4 4     4   150777 use LWP::Authen::Basic;
  4         67920  
  4         162  
5 4     4   1917 use LWP::ConnCache;
  4         4752  
  4         156  
6 4     4   31 use strict;
  4         15  
  4         77  
7 4     4   22 use warnings;
  4         9  
  4         154  
8             BEGIN {
9 4     4   731 $REST::Neo4p::Agent::LWP::UserAgent::VERSION = '0.4001';
10             }
11             sub new {
12 4     4 1 12 my ($class,@args) = @_;
13 4         59 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         12040 my $cache = LWP::ConnCache->new;
18             #TODO FIXME This number should be configurable in some comfortable way
19 4         170 $cache->total_capacity([30]);
20 4         177 $self->conn_cache($cache);
21 4         91 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;