1 package Catalyst::Engine::HTTP;
4 use base 'Catalyst::Engine::Test';
6 use IO::Socket qw(AF_INET INADDR_ANY SOCK_STREAM SOMAXCONN);
10 Catalyst::Engine::HTTP - Catalyst HTTP Engine
14 A script using the Catalyst::Engine::HTTP module might look like:
18 BEGIN { $ENV{CATALYST_ENGINE} = 'HTTP' }
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::Test>.
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 $http = Catalyst::Engine::Test::HTTP->new(
72 address => $connection->peerhost,
73 hostname => gethostbyaddr( $connection->peeraddr, AF_INET ),
75 response => HTTP::Response->new
78 $class->handler($http);
79 $connection->send_response( $http->response );
92 L<Catalyst>, L<HTTP::Daemon>.
96 Sebastian Riedel, C<sri@cpan.org>
97 Christian Hansen, C<ch@ngmedia.com>
101 This program is free software, you can redistribute it and/or modify it under
102 the same terms as Perl itself.
106 package Catalyst::Engine::HTTP::Catalyst;
109 use base 'HTTP::Daemon';
112 "Catalyst/$Catalyst::VERSION";