From: Sebastian Riedel Date: Mon, 28 Mar 2005 22:13:03 +0000 (+0000) Subject: big cleansweep X-Git-Tag: 5.7099_04~1663 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=ca61af20db58c67b3fa27e7277ed3aba5e2af829 big cleansweep --- diff --git a/Changes b/Changes index f7fc273..2aaae4a 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,9 @@ This file documents the revision history for Perl extension Catalyst. - added Test::Pod support - added new server backend with HTTP/1.1 support - added option to run tests against a remote server + - more better docs + IMPORTANT: This release is very incompatible to previous ones + and you have to regenerate the helper scripts again... 4.34 Wed Mar 23 07:00:00 2005 - added some messages to Makefile.PL diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 551f5dd..9dde550 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -180,12 +180,6 @@ sub import { $engine = "Catalyst::Engine::$ENV{CATALYST_ENGINE}" if $ENV{CATALYST_ENGINE}; - if ( $engine eq 'Catalyst::Engine::Server' ) { - $engine = 'Catalyst::Engine::HTTP::Daemon'; - $caller->log->warn( "Catalyst::Engine::Server is deprecated, " - . "using Catalyst::Engine::HTTP::Daemon." ); - } - $engine->require; die qq/Couldn't load engine "$engine", "$@"/ if $@; { diff --git a/lib/Catalyst/Engine/HTTP/Daemon.pm b/lib/Catalyst/Engine/HTTP.pm similarity index 83% rename from lib/Catalyst/Engine/HTTP/Daemon.pm rename to lib/Catalyst/Engine/HTTP.pm index 1e2a211..3201ed9 100644 --- a/lib/Catalyst/Engine/HTTP/Daemon.pm +++ b/lib/Catalyst/Engine/HTTP.pm @@ -1,4 +1,4 @@ -package Catalyst::Engine::HTTP::Daemon; +package Catalyst::Engine::HTTP; use strict; use base 'Catalyst::Engine::Test'; @@ -7,17 +7,15 @@ use IO::Socket qw(AF_INET); =head1 NAME -Catalyst::Engine::HTTP::Daemon - Catalyst HTTP Daemon Engine +Catalyst::Engine::HTTP - Catalyst HTTP Engine =head1 SYNOPSIS -A script using the Catalyst::Engine::HTTP::Daemon module might look like: +A script using the Catalyst::Engine::HTTP module might look like: #!/usr/bin/perl -w - BEGIN { - $ENV{CATALYST_ENGINE} = 'HTTP::Daemon'; - } + BEGIN { $ENV{CATALYST_ENGINE} = 'HTTP' } use strict; use lib '/path/to/MyApp/lib'; @@ -45,7 +43,7 @@ sub run { my $class = shift; my $port = shift || 3000; - my $daemon = Catalyst::Engine::HTTP::Daemon::Catalyst->new( + my $daemon = Catalyst::Engine::HTTP::Catalyst->new( LocalPort => $port, ReuseAddr => 1 ); @@ -99,7 +97,7 @@ the same terms as Perl itself. =cut -package Catalyst::Engine::HTTP::Daemon::Catalyst; +package Catalyst::Engine::HTTP::Catalyst; use strict; use base 'HTTP::Daemon'; diff --git a/lib/Catalyst/Engine/HTTP/Server.pm b/lib/Catalyst/Engine/HTTP/Server.pm deleted file mode 100644 index be23a7d..0000000 --- a/lib/Catalyst/Engine/HTTP/Server.pm +++ /dev/null @@ -1,147 +0,0 @@ -package Catalyst::Engine::HTTP::Server; - -use strict; -use base 'Catalyst::Engine::CGI::NPH'; - -=head1 NAME - -Catalyst::Engine::HTTP::Server - Catalyst HTTP Server Engine - -=head1 SYNOPSIS - -A script using the Catalyst::Engine::HTTP::Server module might look like: - - #!/usr/bin/perl -w - - BEGIN { - $ENV{CATALYST_ENGINE} = 'HTTP::Server'; - } - - use strict; - use lib '/path/to/MyApp/lib'; - use MyApp; - - MyApp->run; - -=head1 DESCRIPTION - -This is the Catalyst engine specialized for development and testing. - -=head1 OVERLOADED METHODS - -This class overloads some methods from C. - -=over 4 - -=item $c->run - -=cut - -sub run { - my $class = shift; - my $port = shift || 3000; - - my $server = Catalyst::Engine::HTTP::Server::Simple->new($port); - - $server->handler( sub { $class->handler } ); - $server->run; -} - -=back - -=head1 SEE ALSO - -L, L. - -=head1 AUTHOR - -Sebastian Riedel, C -Christian Hansen, C - -=head1 COPYRIGHT - -This program is free software, you can redistribute it and/or modify it under -the same terms as Perl itself. - -=cut - -package Catalyst::Engine::HTTP::Server::Simple; - -use strict; -use base 'HTTP::Server::Simple'; - -my %CLEAN_ENV = %ENV; - -sub handler { - my $self = shift; - - if (@_) { - $self->{handler} = shift; - } - - else { - $self->{handler}->(); - } -} - -sub print_banner { - my $self = shift; - - printf( - "You can connect to your server at http://%s:%d/\n", - $self->host || 'localhost', - $self->port - ); -} - -sub accept_hook { - %ENV = ( %CLEAN_ENV, SERVER_SOFTWARE => "Catalyst/$Catalyst::VERSION" ); -} - -our %env_mapping = ( - protocol => "SERVER_PROTOCOL", - localport => "SERVER_PORT", - localname => "SERVER_NAME", - path => "PATH_INFO", - request_uri => "REQUEST_URI", - method => "REQUEST_METHOD", - peeraddr => "REMOTE_ADDR", - peername => "REMOTE_HOST", - query_string => "QUERY_STRING", -); - -sub setup { - no warnings 'uninitialized'; - my $self = shift; - - while ( my ( $item, $value ) = splice @_, 0, 2 ) { - if ( $self->can($item) ) { - $self->$item($value); - } - elsif ( my $k = $env_mapping{$item} ) { - $ENV{$k} = $value; - } - } -} - -sub headers { - my $self = shift; - my $headers = shift; - - while ( my ( $tag, $value ) = splice @{$headers}, 0, 2 ) { - $tag = uc($tag); - $tag =~ s/^COOKIES$/COOKIE/; - $tag =~ s/-/_/g; - $tag = "HTTP_" . $tag - unless $tag =~ m/^CONTENT_(?:LENGTH|TYPE)$/; - - if ( exists $ENV{$tag} ) { - $ENV{$tag} .= "; $value"; - } - else { - $ENV{$tag} = $value; - } - } -} - -1; diff --git a/lib/Catalyst/Helper.pm b/lib/Catalyst/Helper.pm index 4ce4b90..214ea8c 100644 --- a/lib/Catalyst/Helper.pm +++ b/lib/Catalyst/Helper.pm @@ -472,7 +472,7 @@ sub _mk_server { $self->mk_file( "$script\/server.pl", <<"EOF"); $Config{startperl} -w -BEGIN { \$ENV{CATALYST_ENGINE} = 'HTTP::Daemon' } +BEGIN { \$ENV{CATALYST_ENGINE} = 'HTTP' } use strict; use Getopt::Long;