=head1 NAME

IOMux::HTTP::Server - IOMux and LWP based HTTP server

=head1 INHERITANCE

 IOMux::HTTP::Server
   is a IOMux::Service::TCP
   is a IOMux::Handler::Service
   is a IOMux::Handler

=head1 SYNOPSIS

  my $mux  = IOMux::Poll->new;
  my $conn = IOMux::HTTP::Server->new(handler => \&h);
  $mux->add($conn);
  $mux->loop;

=head1 DESCRIPTION

This module implements a basic HTTP connection handler on a socket,
using L<IOMux|IOMux> as basis. This server takes all requests in a single
process, because it is shaped around a C<select> or C<poll> system call:
multiple clients send data to a single process in parallel.

The server understands protocols HTTP version 0.9, 1.0, and 1.1. See
HTTP::Server::Multiplex for a extended server implementation, mimicing
Apache. The connection logic is implemented in L<IOMux::HTTP::Service|IOMux::HTTP::Service>.

See the F<examples/> directory in the distribution for a detailed
template for a complete HTTP server.

=head1 METHODS

=head2 Constructors

=over 4

=item IOMux::HTTP::Server-E<gt>B<new>(OPTIONS)

One object will accept connections on one socket.  When you have more
sockets to listen on, each needs its own object.

You may extend the connection implementation.

 -Option   --Defined in     --Default
  conn_opts  IOMux::Service::TCP  []
  conn_type  IOMux::Service::TCP  IOMux::HTTP::Service
  fh         IOMux::Handler   <required>
  handler                     <required>
  name       IOMux::Handler   'listen tcp $host:$port'

=over 2

=item conn_opts => ARRAY

=item conn_type => CLASS|CODE

=item fh => FILEHANDLE

=item handler => CODE

The CODE points to the routine which get called when a new
connection gets initialized.

=item name => STRING

=back

=item IOMux::HTTP::Server-E<gt>B<open>(MODE, WHAT, OPTIONS)
See L<IOMux::Handler/"Constructors">

=back

=head2 Accessors

=over 4

=item $obj-E<gt>B<clientType>
See L<IOMux::Service::TCP/"Accessors">

=item $obj-E<gt>B<fh>
See L<IOMux::Handler/"Accessors">

=item $obj-E<gt>B<fileno>
See L<IOMux::Handler/"Accessors">

=item $obj-E<gt>B<mux>
See L<IOMux::Handler/"Accessors">

=item $obj-E<gt>B<name>
See L<IOMux::Handler/"Accessors">

=item $obj-E<gt>B<socket>
See L<IOMux::Service::TCP/"Accessors">

=item $obj-E<gt>B<usesSSL>
See L<IOMux::Handler/"Accessors">

=back

=head2 User interface

=head3 Connection

=over 4

=item $obj-E<gt>B<close>([CALLBACK])
See L<IOMux::Handler/"Connection">

=item $obj-E<gt>B<timeout>([TIMEOUT])
See L<IOMux::Handler/"Connection">

=back

=head2 Multiplexer

=head3 Connection

=over 4

=item $obj-E<gt>B<mux_init>(MUX, [HANDLER])
See L<IOMux::Handler/"Connection">

=item $obj-E<gt>B<mux_remove>
See L<IOMux::Handler/"Connection">

=item $obj-E<gt>B<mux_timeout>
See L<IOMux::Handler/"Connection">

=back

=head3 Reading

=over 4

=item $obj-E<gt>B<mux_except_flagged>(FILENO)
See L<IOMux::Handler/"Reading">

=item $obj-E<gt>B<mux_read_flagged>(FILENO)
See L<IOMux::Handler/"Reading">

=back

=head3 Writing

=over 4

=item $obj-E<gt>B<mux_write_flagged>(FILENO)
See L<IOMux::Handler/"Writing">

=back

=head3 Service

=over 4

=item $obj-E<gt>B<mux_connection>(CLIENT)
See L<IOMux::Handler::Service/"Service">

=back

=head2 Helpers

=over 4

=item $obj-E<gt>B<extractSocket>(HASH)

=item IOMux::HTTP::Server-E<gt>B<extractSocket>(HASH)
See L<IOMux::Handler/"Helpers">

=item $obj-E<gt>B<fdset>(STATE, READ, WRITE, ERROR)
See L<IOMux::Handler/"Helpers">

=item $obj-E<gt>B<show>
See L<IOMux::Handler/"Helpers">

=back

=head1 SEE ALSO

This module is part of IOMux-HTTP distribution version 0.11,
built on January 27, 2011. Website: F<http://perl.overmeer.net/>
All modules in this suite:
L</Any::Daemon>,
L</IOMux>, and
L</IOMux::HTTP>.

Please post questions or ideas to F<perl@overmeer.net>

=head1 LICENSE

Copyrights 2011 by Mark Overmeer. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://www.perl.com/perl/misc/Artistic.html>

