1 package AnyEvent
::HTTPD
::HTTPServer
;
9 use AnyEvent
::HTTPD
::HTTPConnection
;
11 our @ISA = qw
/Object::Event/;
15 AnyEvent::HTTPD::HTTPServer - A simple and plain http server
19 This class handles incoming TCP connections for HTTP clients.
20 It's used by L<AnyEvent::HTTPD> to do it's job.
22 It has no public interface yet.
24 =head1 COPYRIGHT & LICENSE
26 Copyright 2008 Robin Redeker, all rights reserved.
28 This program is free software; you can redistribute it and/or modify it
29 under the same terms as Perl itself.
35 my $class = ref($this) || $this;
39 tcp_server
$self->{host
}, $self->{port
}, sub {
42 $self->event (error
=> "couldn't accept client: $!");
45 $self->accept_connection ($fh);
51 sub accept_connection
{
54 my $htc = AnyEvent
::HTTPD
::HTTPConnection
->new (fh
=> $fh);
55 $self->{handles
}->{$htc} = $htc;
57 $htc->reg_cb (disconnect
=> sub {
58 delete $self->{handles
}->{$_[0]};
59 $self->event (disconnect
=> $_[0], $_[1])
62 $self->event (connect => $htc);