RPC/Legacy/Server/Daemon.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 74 CC 3 SCAR 15.5
CC
3
Cov
0%
new
12.0
handle
2.0
retrieve_json_from_post
2.0
CRAP 4.7
1 ##############################################################################
2 package JSON::RPC::Legacy::Server::Daemon;
3  
4 use strict;
5 use JSON::RPC::Legacy::Server; # for old Perl 5.005
6 use base qw(JSON::RPC::Legacy::Server);
7  
8 $JSON::RPC::Legacy::Server::Daemon::VERSION = '1.06';
9  
10 use Data::Dumper;
11  
12 sub new {
13 my $class = shift;
14 my $self = $class->SUPER::new();
15 my $pkg;
16  
17 if( grep { $_ =~ /^SSL_/ } @_ ){
18 $self->{_daemon_pkg} = $pkg = 'HTTP::Daemon::SSL';
19 }
20 else{
21 $self->{_daemon_pkg} = $pkg = 'HTTP::Daemon';
22 }
23 eval qq| require $pkg; |;
24 if($@){ die $@ }
25  
26 $self->{_daemon} ||= $pkg->new(@_) or die;
27  
28 return $self;
29 }
30  
31  
32 sub handle {
33 my $self = shift;
34 my %opt = @_;
35 my $d = $self->{_daemon} ||= $self->{_daemon_pkg}->new(@_) or die;
36  
37 while (my $c = $d->accept) {
38 $self->{con} = $c;
39 while (my $r = $c->get_request) {
40 $self->request($r);
41 $self->path_info($r->url->path);
42 $self->SUPER::handle();
43 last;
44 }
45 $c->close;
46 }
47  
48 }
49  
50  
51 sub retrieve_json_from_post {
52 return $_[0]->request->content;
53 }
54  
55  
56 sub retrieve_json_from_get {
57 }
58  
59  
60 sub response {
61 my ($self, $response) = @_;
62 $self->{con}->send_response($response);
63 }
64  
65 1;
66 __END__