1 package Catalyst::Engine::HTTP::Server;
4 use base 'Catalyst::Engine::CGI::NPH';
8 Catalyst::Engine::HTTP::Server - Catalyst HTTP Server Engine
12 A script using the Catalyst::Engine::HTTP::Server module might look like:
17 $ENV{CATALYST_ENGINE} = 'HTTP::Server';
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::CGI::NPH>.
42 my $port = shift || 3000;
44 my $server = Catalyst::Engine::Server::Simple->new($port);
46 $server->handler( sub { $class->handler } );
54 L<Catalyst>, L<HTTP::Server::Simple>.
58 Sebastian Riedel, C<sri@cpan.org>
59 Christian Hansen, C<ch@ngmedia.com>
63 This program is free software, you can redistribute it and/or modify it under
64 the same terms as Perl itself.
68 package Catalyst::Engine::Server::Simple;
71 use base 'HTTP::Server::Simple';
79 $self->{handler} = shift;
91 "You can connect to your server at http://%s:%d/\n",
92 $self->host || 'localhost',
98 %ENV = ( %CLEAN_ENV, SERVER_SOFTWARE => "Catalyst/$Catalyst::VERSION" );
102 protocol => "SERVER_PROTOCOL",
103 localport => "SERVER_PORT",
104 localname => "SERVER_NAME",
106 request_uri => "REQUEST_URI",
107 method => "REQUEST_METHOD",
108 peeraddr => "REMOTE_ADDR",
109 peername => "REMOTE_HOST",
110 query_string => "QUERY_STRING",
114 no warnings 'uninitialized';
117 while ( my ( $item, $value ) = splice @_, 0, 2 ) {
118 if ( $self->can($item) ) {
119 $self->$item($value);
121 elsif ( my $k = $env_mapping{$item} ) {
131 while ( my ( $tag, $value ) = splice @{$headers}, 0, 2 ) {
133 $tag =~ s/^COOKIES$/COOKIE/;
135 $tag = "HTTP_" . $tag
136 unless $tag =~ m/^CONTENT_(?:LENGTH|TYPE)$/;
138 if ( exists $ENV{$tag} ) {
139 $ENV{$tag} .= "; $value";