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