1 package Catalyst::Engine::Server;
4 use base 'Catalyst::Engine::CGI';
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>.
30 my $port = shift || 3000;
33 my $server = Catalyst::Engine::Server::Simple->new($port);
35 $server->handler( sub { $script ? print `$script` : $class->handler } );
43 L<Catalyst>, L<HTTP::Server::Simple>.
47 Sebastian Riedel, C<sri@cpan.org>
48 Christian Hansen, C<ch@ngmedia.com>
52 This program is free software, you can redistribute it and/or modify it under
53 the same terms as Perl itself.
57 package Catalyst::Engine::Server::Simple;
60 use base 'HTTP::Server::Simple';
68 $self->{handler} = shift;
80 "You can connect to your server at http://%s:%d/\n",
81 $self->host || 'localhost',
87 %ENV = ( %CLEAN_ENV, SERVER_SOFTWARE => "Catalyst/$Catalyst::VERSION" );
91 protocol => "SERVER_PROTOCOL",
92 localport => "SERVER_PORT",
93 localname => "SERVER_NAME",
95 request_uri => "REQUEST_URI",
96 method => "REQUEST_METHOD",
97 peeraddr => "REMOTE_ADDR",
98 peername => "REMOTE_HOST",
99 query_string => "QUERY_STRING",
103 no warnings 'uninitialized';
106 while ( my ( $item, $value ) = splice @_, 0, 2 ) {
107 if ( $self->can($item) ) {
108 $self->$item($value);
110 elsif ( my $k = $env_mapping{$item} ) {
120 while ( my ( $tag, $value ) = splice @{$headers}, 0, 2 ) {
122 $tag =~ s/^COOKIES$/COOKIE/;
124 $tag = "HTTP_" . $tag
125 unless $tag =~ m/^CONTENT_(?:LENGTH|TYPE)$/;
127 if ( exists $ENV{$tag} ) {
128 $ENV{$tag} .= "; $value";