1 package Catalyst::Engine::HTTP;
4 use base 'Catalyst::Engine::Test';
6 use IO::Socket qw(AF_INET 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 while ( my $request = $connection->get_request ) {
65 $request->uri->scheme('http'); # Force URI::http
66 $request->uri->host( $base->host );
67 $request->uri->port( $base->port );
69 my $lwp = Catalyst::Engine::Test::LWP->new(
71 address => $connection->peerhost,
72 hostname => gethostbyaddr( $connection->peeraddr, AF_INET )
75 $class->handler($lwp);
76 $connection->send_response( $lwp->response );
88 L<Catalyst>, L<HTTP::Daemon>.
92 Sebastian Riedel, C<sri@cpan.org>
93 Christian Hansen, C<ch@ngmedia.com>
97 This program is free software, you can redistribute it and/or modify it under
98 the same terms as Perl itself.
102 package Catalyst::Engine::HTTP::Catalyst;
105 use base 'HTTP::Daemon';
108 "Catalyst/$Catalyst::VERSION";