1 package Catalyst::Engine::Server;
4 use base 'Catalyst::Engine::CGI::NPH';
8 Catalyst::Engine::Server - Catalyst Server Engine
16 This is the Catalyst engine specialized for development and testing.
18 =head1 OVERLOADED METHODS
20 This class overloads some methods from C<Catalyst::Engine::CGI::NPH>.
30 my $port = shift || 3000;
32 my $server = Catalyst::Engine::Server::Simple->new($port);
34 $server->handler( sub { $class->handler } );
42 L<Catalyst>, L<HTTP::Server::Simple>.
46 Sebastian Riedel, C<sri@cpan.org>
47 Christian Hansen, C<ch@ngmedia.com>
51 This program is free software, you can redistribute it and/or modify it under
52 the same terms as Perl itself.
56 package Catalyst::Engine::Server::Simple;
59 use base 'HTTP::Server::Simple';
67 $self->{handler} = shift;
79 "You can connect to your server at http://%s:%d/\n",
80 $self->host || 'localhost',
86 %ENV = ( %CLEAN_ENV, SERVER_SOFTWARE => "Catalyst/$Catalyst::VERSION" );
90 protocol => "SERVER_PROTOCOL",
91 localport => "SERVER_PORT",
92 localname => "SERVER_NAME",
94 request_uri => "REQUEST_URI",
95 method => "REQUEST_METHOD",
96 peeraddr => "REMOTE_ADDR",
97 peername => "REMOTE_HOST",
98 query_string => "QUERY_STRING",
102 no warnings 'uninitialized';
105 while ( my ( $item, $value ) = splice @_, 0, 2 ) {
106 if ( $self->can($item) ) {
107 $self->$item($value);
109 elsif ( my $k = $env_mapping{$item} ) {
119 while ( my ( $tag, $value ) = splice @{$headers}, 0, 2 ) {
121 $tag =~ s/^COOKIES$/COOKIE/;
123 $tag = "HTTP_" . $tag
124 unless $tag =~ m/^CONTENT_(?:LENGTH|TYPE)$/;
126 if ( exists $ENV{$tag} ) {
127 $ENV{$tag} .= "; $value";