File Coverage

blib/lib/POEx/HTTP/Server/Connection.pm
Criterion Covered Total %
statement 32 57 56.1
branch 0 4 0.0
condition n/a
subroutine 11 26 42.3
pod 15 21 71.4
total 58 108 53.7


line stmt bran cond sub pod time code
1             # $Id: Connection.pm 716 2010-12-17 16:29:05Z fil $
2             # Copyright 2010 Philip Gwyn
3             package POEx::HTTP::Server::Connection;
4              
5 13     13   3217 use strict;
  13         42  
  13         407  
6 13     13   65 use warnings;
  13         28  
  13         362  
7 13     13   72 use Socket;
  13         21  
  13         11239  
8              
9 13     13   217 use Scalar::Util qw( blessed );
  13         21  
  13         8999  
10              
11             sub new
12             {
13 17     17 0 76 my( $package, $ID, $socket ) = @_;
14 17         108 my $self = bless {ID=>$ID}, shift;
15 17         116 $self->__socket( $socket );
16 17         100 return $self;
17             }
18              
19             sub __socket
20             {
21 17     17   42 my( $self, $socket ) = @_;
22              
23 17         162 my $peername = getpeername( $socket );
24 17         93 my $sockname = getsockname( $socket );
25              
26 17         221 my @in = sockaddr_in($peername);
27 17         280 $self->{remote_addr} = $in[1];
28 17         212 $self->{remote_ip} = inet_ntoa( $self->{remote_addr} );
29 17         44 $self->{remote_port} = $in[0];
30              
31 17         57 @in = sockaddr_in($sockname);
32 17         180 $self->{local_addr} = $in[1];
33 17         123 $self->{local_ip} = inet_ntoa($self->{local_addr});
34 17         74 $self->{local_port} = $in[0];
35             }
36              
37             ######################################
38 12     12 1 4639 sub ID { $_[0]->{ID} }
39              
40 0     0 1 0 sub remote_addr { $_[0]->{remote_addr} }
41 0     0 1 0 sub peeraddr { $_[0]->{remote_addr} }
42 1     1 1 13 sub remote_host { $_[0]->{remote_ip} }
43 0     0 1 0 sub peerhost { $_[0]->{remote_ip} }
44 0     0 1 0 sub remote_ip { $_[0]->{remote_ip} }
45 1     1 1 10 sub remote_port { $_[0]->{remote_port} }
46 0     0 1 0 sub peerport { $_[0]->{remote_port} }
47              
48 0     0 1 0 sub local_addr { $_[0]->{local_addr} }
49 0     0 1 0 sub hostaddr { $_[0]->{local_addr} }
50 1     1 1 6 sub local_host { $_[0]->{local_ip} }
51 0     0 1 0 sub hosthost { $_[0]->{local_ip} }
52 0     0 1 0 sub local_ip { $_[0]->{local_ip} }
53 1     1 1 10 sub local_port { $_[0]->{local_port} }
54 0     0 1   sub hostport { $_[0]->{local_port} }
55              
56              
57             ######################################
58             sub user {
59 0     0 0   my $self = @_;
60 0           my $rv = $self->{user};
61 0 0         if (@_ == 2) { $self->{user} = $_[1] }
  0            
62 0           return $rv;
63             }
64              
65             sub authtype {
66 0     0 0   my $self = @_;
67 0           my $rv = $self->{authtype};
68 0 0         if (@_ == 2) { $self->{authtype} = $_[1] }
  0            
69 0           return $rv;
70             }
71            
72             sub aborted {
73 0     0 0   return $_[0]->{aborted};
74             }
75            
76             sub fileno {
77 0     0 0   return 0;
78             }
79            
80             sub clone {
81 0     0 0   my $self = @_;
82 0           my $new = bless { %$self };
83 0           return $new;
84             }
85            
86            
87             1;
88              
89             __END__