line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Declare our package |
2
|
|
|
|
|
|
|
package POE::Component::Server::SimpleHTTP::Connection; |
3
|
|
|
|
|
|
|
|
4
|
7
|
|
|
7
|
|
1948
|
use strict; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
170
|
|
5
|
7
|
|
|
7
|
|
31
|
use warnings; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
350
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '2.20'; |
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
35
|
use Socket qw( inet_ntoa unpack_sockaddr_in ); |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
378
|
|
10
|
7
|
|
|
7
|
|
33
|
use POE; |
|
7
|
|
|
|
|
29
|
|
|
7
|
|
|
|
|
58
|
|
11
|
|
|
|
|
|
|
|
12
|
7
|
|
|
7
|
|
7089
|
use Moose; |
|
7
|
|
|
|
|
2977221
|
|
|
7
|
|
|
|
|
58
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has dead => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
isa => 'Bool', |
17
|
|
|
|
|
|
|
default => 0, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has ssl => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
isa => 'Bool', |
23
|
|
|
|
|
|
|
default => 0, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has sslcipher => ( |
27
|
|
|
|
|
|
|
is => 'rw', |
28
|
|
|
|
|
|
|
default => undef, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has remote_ip => ( |
32
|
|
|
|
|
|
|
is => 'ro', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has remote_port => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has remote_addr => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has local_ip => ( |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has local_port => ( |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has local_addr => ( |
52
|
|
|
|
|
|
|
is => 'ro', |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has ID => ( |
56
|
|
|
|
|
|
|
is => 'rw', |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has OnClose => ( |
60
|
|
|
|
|
|
|
is => 'ro', |
61
|
|
|
|
|
|
|
default => sub { { } }, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub BUILDARGS { |
65
|
9
|
|
|
9
|
1
|
22
|
my $class = shift; |
66
|
|
|
|
|
|
|
|
67
|
9
|
|
|
|
|
23
|
my $self = { }; |
68
|
|
|
|
|
|
|
|
69
|
9
|
|
|
|
|
21
|
my $socket = shift; |
70
|
|
|
|
|
|
|
|
71
|
9
|
|
|
|
|
22
|
eval { |
72
|
9
|
|
|
|
|
101
|
( $self->{'remote_port'}, $self->{'remote_addr'} ) = |
73
|
|
|
|
|
|
|
unpack_sockaddr_in( getpeername($socket) ); |
74
|
9
|
|
|
|
|
90
|
$self->{'remote_ip'} = inet_ntoa( $self->{'remote_addr'} ); |
75
|
|
|
|
|
|
|
|
76
|
9
|
|
|
|
|
64
|
( $self->{'local_port'}, $self->{'local_addr'} ) = |
77
|
|
|
|
|
|
|
unpack_sockaddr_in( getsockname($socket) ); |
78
|
9
|
|
|
|
|
48
|
$self->{'local_ip'} = inet_ntoa( $self->{'local_addr'} ); |
79
|
|
|
|
|
|
|
}; |
80
|
|
|
|
|
|
|
|
81
|
9
|
50
|
|
|
|
37
|
if ($@) { |
82
|
0
|
|
|
|
|
0
|
return undef; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
9
|
|
|
|
|
418
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _on_close { |
89
|
2
|
|
|
2
|
|
53
|
my ( $self, $sessionID, $state, @args ) = @_; |
90
|
2
|
50
|
|
|
|
8
|
if ($state) { |
91
|
2
|
|
|
|
|
98
|
$self->OnClose->{$sessionID} = [ $state, @args ]; |
92
|
2
|
|
|
|
|
13
|
$poe_kernel->refcount_increment( $sessionID, __PACKAGE__ ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
else { |
95
|
0
|
|
|
|
|
0
|
my $data = delete $self->OnClose->{$sessionID}; |
96
|
0
|
0
|
|
|
|
0
|
$poe_kernel->refcount_decrement( $sessionID, __PACKAGE__ ) if $data; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub DEMOLISH { |
101
|
9
|
|
|
9
|
0
|
40
|
my ($self) = @_; |
102
|
9
|
50
|
|
|
|
22
|
while ( my ( $sessionID, $data ) = each %{ $self->OnClose || {} } ) { |
|
11
|
|
|
|
|
608
|
|
103
|
2
|
|
|
|
|
18
|
$poe_kernel->call( $sessionID, @$data ); |
104
|
2
|
|
|
|
|
135
|
$poe_kernel->refcount_decrement( $sessionID, __PACKAGE__ ); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
7
|
|
|
7
|
|
54312
|
no Moose; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
39
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# End of module |
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__END__ |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 NAME |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
POE::Component::Server::SimpleHTTP::Connection - Stores connection information for SimpleHTTP |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 SYNOPSIS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
use POE::Component::Server::SimpleHTTP::Connection; |
124
|
|
|
|
|
|
|
my $connection = POE::Component::Server::SimpleHTTP::Connection->new( $socket ); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# Print some stuff |
127
|
|
|
|
|
|
|
print $connection->remote_port; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 DESCRIPTION |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This module simply holds some information from a SimpleHTTP connection. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 METHODS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my $connection = POE::Component::Server::SimpleHTTP::Connection->new( $socket ); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$connection->remote_ip(); # Returns remote ip in dotted quad format ( 1.1.1.1 ) |
138
|
|
|
|
|
|
|
$connection->remote_port(); # Returns remote port |
139
|
|
|
|
|
|
|
$connection->remote_addr(); # Returns true remote address, consult the L<Socket> POD |
140
|
|
|
|
|
|
|
$connection->local_addr(); # Returns true local address, same as above |
141
|
|
|
|
|
|
|
$connection->local_ip(); # Returns local ip in dotted quad format ( 1.1.1.1 ) |
142
|
|
|
|
|
|
|
$connection->local_port(); # Returns local port |
143
|
|
|
|
|
|
|
$connection->dead(); # Returns a boolean value whether the socket is closed or not |
144
|
|
|
|
|
|
|
$connection->ssl(); # Returns a boolean value whether the socket is SSLified or not |
145
|
|
|
|
|
|
|
$connection->sslcipher(); # Returns the SSL Cipher type or undef if not SSL |
146
|
|
|
|
|
|
|
$connection->ID(); # unique ID of this connection |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 EXPORT |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Nothing. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 SEE ALSO |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L<POE::Component::Server::SimpleHTTP>, |
155
|
|
|
|
|
|
|
L<POE::Component::Server::SimpleHTTP::Response> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 AUTHOR |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Apocalypse E<lt>apocal@cpan.orgE<gt> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Chris C<BinGOs> Williams <chris@bingosnet.co.uk> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Copyright E<copy> Apocalypse and Chris Williams |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
168
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |