1 package Catalyst::Engine::HTTP::Daemon;
4 use base 'Catalyst::Engine::HTTP::Base';
6 use IO::Socket qw(AF_INET INADDR_ANY SOCK_STREAM SOMAXCONN);
10 Catalyst::Engine::HTTP::Daemon - Catalyst HTTP Daemon Engine
14 A script using the Catalyst::Engine::HTTP::Daemon module might look like:
18 BEGIN { $ENV{CATALYST_ENGINE} = 'HTTP::Daemon' }
21 use lib '/path/to/MyApp/lib';
28 This is the Catalyst engine specialized for development and testing.
30 =head1 OVERLOADED METHODS
32 This class overloads some methods from C<Catalyst::Engine::HTTP::Base>.
40 $SIG{'PIPE'} = 'IGNORE';
44 my $port = shift || 3000;
46 my $daemon = Catalyst::Engine::HTTP::Catalyst->new(
54 die("Failed to create daemon: $!\n");
57 my $base = URI->new( $daemon->url )->canonical;
59 printf( "You can connect to your server at %s\n", $base );
61 while ( my $connection = $daemon->accept ) {
63 $connection->timeout(5);
65 while ( my $request = $connection->get_request ) {
67 $request->uri->scheme('http'); # Force URI::http
68 $request->uri->host( $request->header('Host') || $base->host );
69 $request->uri->port( $base->port );
71 my $hostname = gethostbyaddr( $connection->peeraddr, AF_INET );
73 my $http = Catalyst::Engine::HTTP::Base::struct->new(
74 address => $connection->peerhost,
75 hostname => $hostname || $connection->peerhost,
77 response => HTTP::Response->new
80 $class->handler($http);
81 $connection->send_response( $http->response );
94 L<Catalyst>, L<Catalyst::Engine>, L<Catalyst::Engine::HTTP::Base>,
99 Sebastian Riedel, C<sri@cpan.org>
100 Christian Hansen, C<ch@ngmedia.com>
104 This program is free software, you can redistribute it and/or modify it under
105 the same terms as Perl itself.
109 package Catalyst::Engine::HTTP::Catalyst;
112 use base 'HTTP::Daemon';
114 $HTTP::Daemon::PROTO = 'HTTP/0.9';
117 "Catalyst/$Catalyst::VERSION";