1 package Catalyst::Engine::LWP::Daemon;
4 use base 'Catalyst::Engine::LWP';
6 use IO::Socket qw(AF_INET);
10 Catalyst::Engine::LWP::Daemon - Catalyst LWP Daemon Engine
14 A script using the Catalyst::Engine::LWP::Daemon module might look like:
19 $ENV{CATALYST_ENGINE} = 'LWP::Daemon';
23 use lib '/path/to/MyApp/lib';
30 This is the Catalyst engine specialized for development and testing.
32 =head1 OVERLOADED METHODS
34 This class overloads some methods from C<Catalyst::Engine::LWP>.
42 $SIG{'PIPE'} = 'IGNORE';
46 my $port = shift || 3000;
48 my $daemon = Catalyst::Engine::LWP::Daemon::Catalyst->new(
54 die("Failed to create daemon: $!\n");
57 printf( "You can connect to your server at %s\n", $daemon->url );
59 while ( my $connection = $daemon->accept ) {
61 while ( my $request = $connection->get_request ) {
63 $request->uri->scheme('http'); # Force URI::http
65 my $lwp = Catalyst::Engine::LWP::HTTP->new(
67 address => $connection->peerhost,
68 hostname => gethostbyaddr( $connection->peeraddr, AF_INET )
71 $class->handler($lwp);
72 $connection->send_response( $lwp->response );
84 L<Catalyst>, L<HTTP::Daemon>.
88 Sebastian Riedel, C<sri@cpan.org>
89 Christian Hansen, C<ch@ngmedia.com>
93 This program is free software, you can redistribute it and/or modify it under
94 the same terms as Perl itself.
98 package Catalyst::Engine::LWP::Daemon::Catalyst;
101 use base 'HTTP::Daemon';
104 "Catalyst/$Catalyst::VERSION";