Any-Daemon-HTTP
view release on metacpan or search on metacpan
lib/Any/Daemon/HTTP.pod view on Meta::CPAN
=item standard_headers => ARRAY
Pass a list of key-value pairs which will be added to each produced
response. They are fed into HTTP::Headers subroutine push_header.
=item user => UID|USERNAME
=item vhost_class => PACKAGE
[0.22] The PACKAGE must extend the default class. See the
L<Any::Daemon::HTTP::VirtualHost/DETAILS> about creating your own virtual
hosts.
=item vhosts => VHOST|PACKAGE|\%options|ARRAY
The %options are passed to L<addVirtualHost()|Any::Daemon::HTTP/"Host administration">, to create a virtual host
object under fly. You may also pass an initialized
L<Any::Daemon::HTTP::VirtualHost|Any::Daemon::HTTP::VirtualHost> object, or a PACKAGE name to be used
for the default vhost. An ARRAY contains a mixture of vhost definitions.
[0.24] Same as option C<vhost>.
=item workdir => DIRECTORY
=back
=back
=head2 Accessors
Extends L<"Accessors" in Any::Daemon|Any::Daemon/"Accessors">.
=over 4
=item $obj-E<gt>B<hosts>()
Returns a list of hostnames used to connect to the sockets.
=item $obj-E<gt>B<pidFilename>()
Inherited, see L<Any::Daemon/"Accessors">
=item $obj-E<gt>B<protocol>()
Returns C<HTTP>, C<HTTPS>, or C<FCGI> to express the procotol used. All
implementations are based on L<HTTP::Daemon> (part of LWP)
=item $obj-E<gt>B<sockets>()
Returns all the sockets we listen on. This list is the result of
L<new(listen)|Any::Daemon::HTTP/"METHODS">.
=item $obj-E<gt>B<workdir>()
Inherited, see L<Any::Daemon/"Accessors">
=back
=head2 Host administration
VirtualHosts and a global proxy can be added in a any order. They
can also be added at run-time!
When a request arrives, it contains a C<Host> header which is used to
select the right object. When a VirtualHost has this name or alias,
that will be address. Otherwise, if there are global proxy objects,
they are tried one after the other to see whether the forwardRewrite()
reports that it accepts the request. If this all fails, then the request
is redirected to the host named (or aliased) 'default'. As last resort,
you get an error.
=over 4
=item $obj-E<gt>B<addProxy>($object|\%options|%options)
Add a L<Any::Daemon::HTTP::Proxy|Any::Daemon::HTTP::Proxy> object which has a C<proxy_map>,
about how to handle requests for incoming hosts. The proxy settings
will be tried in order of addition, only when there are no virtual
hosts addressed.
=item $obj-E<gt>B<addVirtualHost>($vhost|\%options|%options)
Adds a new virtual host to the knowledge of the daemon. Can be used
at run-time, until the daemon goes into 'run' mode (starts forking
childs) The added virtual host object is returned.
The $vhost is an already prepared VirtualHost object. With %options,
the VirtualHost object gets created for you with those %options.
See L<Any::Daemon::HTTP::VirtualHost::new()|Any::Daemon::HTTP::VirtualHost/"Constructors"> for %options.
See the manual page for L<Any::Daemon::HTTP::VirtualHost|Any::Daemon::HTTP::VirtualHost> on how you
can cleanly extend the class for your own purpose.
example:
# Simple version
$http->addVirtualHost
( name => 'images'
, aliases => 'images.example.com'
, documents => '/home/www/images
);
# Own virtual host, usually in separate pm-file
{ package My::VHost;
use parent 'Any::Daemon::HTTP::VirtualHost';
...
}
my $vhost = My::VHost->new(...);
$http->addVirtualHost($vhost);
# Implicitly add virtual hosts
push @vhosts, $vhost;
my $http = Any::Daemon::HTTP->new
( ...
, vhosts => \@vhosts
);
=item $obj-E<gt>B<findProxy>($session, $request, $host)
[0.24] Find the first proxy which is mapping the URI of the $request. Returns a
pair, containing the proxy and the location where it points to.
Usually, in a proxy, the request needs to be in absolute form in the
request header. However, we can be more
=item $obj-E<gt>B<proxies>()
( run in 2.159 seconds using v1.01-cache-2.11-cpan-13bb782fe5a )