Application/Daemon/httpd.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 57 CC 3 SCAR 16.1
CC
3
Cov
0%
handler
12.0
processSocketCreate
2.0
requestHandler
2.0
CRAP 5.0
1 package Proc::Application::Daemon::httpd;
2  
3 use Proc::Application::Daemon;
4 use base qw(Proc::Application::Daemon);
5  
6 use HTTP::Daemon;
7 use HTTP::Status;
8  
9 sub processSocketCreate
10 {
11 my ( $this, $option, $params ) = @_;
12 my %params = $this->_decodeOption ( $params );
13 $this->{mainSocket} = new HTTP::Daemon ( Reuse => 1,
14 Proto => 'tcp',
15 Type => SOCK_STREAM,
16 Listen => 10,
17 %params ) || die "Can't create HTTPD: $!";
18 }
19  
20 sub requestHandler
21 {
22 my ( $this, $request ) = @_;
23 }
24  
25 sub connection
26 {
27 my $this = shift;
28 $this->socket;
29 }
30  
31 sub handler
32 {
33 my $this = shift;
34 while ( 1 )
35 {
36 my $request;
37 eval
38 {
39 local $SIG{ALRM} = sub { die "timeout get http request" };
40 alarm 15;
41 $request = $this->connection->get_request;
42 alarm 0;
43 };
44 die $@ if $@;
45 $request || last;
46 eval { $this->requestHandler ( $request ); };
47 if ( $@ )
48 {
49 $this->log->error ( $@ );
50 $this->connection->send_error( 500, "Server error" );
51 }
52 }
53 }
54  
55 1;
56  
57 __END__