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>.
41 my ( $class, $client ) = @_;
45 while ( my $request = $client->get_request ) {
47 $request->uri->scheme('http'); # Force URI::http
48 $request->uri->host( $request->header('Host') || $client->sockhost );
49 $request->uri->port( $client->sockport );
51 my $hostname = gethostbyaddr( $client->peeraddr, AF_INET );
53 my $http = Catalyst::Engine::HTTP::Base::struct->new(
54 address => $client->peerhost,
55 hostname => $hostname || $client->peerhost,
57 response => HTTP::Response->new
60 $class->SUPER::handler($http);
62 $client->send_response( $http->response );
74 my $port = shift || 3000;
76 $SIG{'PIPE'} = 'IGNORE';
78 $HTTP::Daemon::PROTO = 'HTTP/1.0'; # For now until we resolve the blocking
79 # issues with HTTP 1.1
81 my $daemon = Catalyst::Engine::HTTP::Daemon::Catalyst->new(
88 my $base = URI->new( $daemon->url )->canonical;
90 printf( "You can connect to your server at %s\n", $base );
92 while ( my $client = $daemon->accept ) {
93 $class->handler($client);
101 L<Catalyst>, L<Catalyst::Engine>, L<Catalyst::Engine::HTTP::Base>,
106 Sebastian Riedel, C<sri@cpan.org>
107 Christian Hansen, C<ch@ngmedia.com>
111 This program is free software, you can redistribute it and/or modify it under
112 the same terms as Perl itself.
116 package Catalyst::Engine::HTTP::Daemon::Catalyst;
119 use base 'HTTP::Daemon';
122 "Catalyst/$Catalyst::VERSION";