From: Guillermo Roditi Date: Mon, 23 Jun 2008 21:18:09 +0000 (+0000) Subject: reverting (most of) the whitespace changes X-Git-Tag: 5.8000_03~106 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=ac5c933bdd463558e8d621507a53a7b247a9093e;hp=e5ecd5bc38bac3e2fcfaf643ea2a4c6ab46d7e57 reverting (most of) the whitespace changes r17535@martha (orig r7626): matthewt | 2008-04-22 15:59:49 -0400 --- diff --git a/Makefile.PL b/Makefile.PL index bf4ab7f..6ab7e11 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,6 +1,6 @@ use inc::Module::Install 0.64; -use 5.008001; +use 5.008001; perl_version '5.8.1'; name 'Catalyst-Runtime'; @@ -40,7 +40,7 @@ if (-e 'inc/.author') { build_requires 'Test::Pod' => 1.14; build_requires 'Test::Pod::Coverage' => 1.04; - if ($^O eq 'darwin') { + if ($^O eq 'darwin') { my $osx_ver = `/usr/bin/sw_vers -productVersion`; chomp $osx_ver; @@ -50,7 +50,7 @@ if (-e 'inc/.author') { makemaker_args(dist => { PREOP => qq{\@if [ "\$\$$attr" != "true" ]; then}. qq{ echo "You must set the ENV variable $attr to true,"; }. - ' echo "to avoid getting resource forks in your dist."; exit 255; fi' }); + ' echo "to avoid getting resource forks in your dist."; exit 255; fi' }); } } @@ -70,7 +70,7 @@ print <<"EOF"; perl -MCPANPLUS -e 'install Catalyst::Devel' # or perl -MCPAN -e 'install Catalyst::Devel' - To get some commonly used plugins, as well as the TT view and DBIC + To get some commonly used plugins, as well as the TT view and DBIC model, install Task::Catalyst in the same way. Have fun! diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 7c151db..c7007ab 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -62,7 +62,7 @@ our $DETACH = "catalyst_detach\n"; #maybe we should just make them attributes with a default? __PACKAGE__->mk_classdata($_) for qw/components arguments dispatcher engine log dispatcher_class - engine_class context_class request_class response_class stats_class + engine_class context_class request_class response_class stats_class setup_finished/; __PACKAGE__->dispatcher_class('Catalyst::Dispatcher'); @@ -130,30 +130,30 @@ documentation and tutorials. ### in lib/MyApp.pm use Catalyst qw/-Debug/; # include plugins here as well - + ### In lib/MyApp/Controller/Root.pm (autocreated) sub foo : Global { # called for /foo, /foo/1, /foo/1/2, etc. my ( $self, $c, @args ) = @_; # args are qw/1 2/ for /foo/1/2 $c->stash->{template} = 'foo.tt'; # set the template # lookup something from db -- stash vars are passed to TT - $c->stash->{data} = + $c->stash->{data} = $c->model('Database::Foo')->search( { country => $args[0] } ); if ( $c->req->params->{bar} ) { # access GET or POST parameters $c->forward( 'bar' ); # process another action - # do something else after forward returns + # do something else after forward returns } } - + # The foo.tt TT template can use the stash data from the database [% WHILE (item = data.next) %] [% item.foo %] [% END %] - + # called for /bar/of/soap, /bar/of/soap/10, etc. sub bar : Path('/bar/of/soap') { ... } # called for all actions, from the top-most controller downwards - sub auto : Private { + sub auto : Private { my ( $self, $c ) = @_; if ( !$c->user_exists ) { # Catalyst::Plugin::Authentication $c->res->redirect( '/login' ); # require login @@ -161,9 +161,9 @@ documentation and tutorials. } return 1; # success; carry on to next action } - + # called after all actions are finished - sub end : Private { + sub end : Private { my ( $self, $c ) = @_; if ( scalar @{ $c->error } ) { ... } # handle errors return if $c->res->body; # already have a response @@ -173,20 +173,20 @@ documentation and tutorials. ### in MyApp/Controller/Foo.pm # called for /foo/bar sub bar : Local { ... } - + # called for /blargle sub blargle : Global { ... } - + # an index action matches /foo, but not /foo/1, etc. sub index : Private { ... } - + ### in MyApp/Controller/Foo/Bar.pm # called for /foo/bar/baz sub baz : Local { ... } - + # first Root auto is called, then Foo auto, then this sub auto : Private { ... } - + # powerful regular expression paths are also possible sub details : Regex('^product/(\w+)/details$') { my ( $self, $c ) = @_; @@ -267,7 +267,7 @@ from the system environment with CATALYST_STATS or _STATS. The environment settings override the application, with _STATS having the highest priority. -e.g. +e.g. use Catalyst qw/-Stats=1/ @@ -338,8 +338,8 @@ sub forward { my $c = shift; $c->dispatcher->forward( $c, @_ ) } =head2 $c->detach() -The same as C, but doesn't return to the previous action when -processing is finished. +The same as C, but doesn't return to the previous action when +processing is finished. When called with no arguments it escapes the processing chain entirely. @@ -366,7 +366,7 @@ Catalyst). $c->stash->{foo} = $bar; $c->stash( { moose => 'majestic', qux => 0 } ); $c->stash( bar => 1, gorch => 2 ); # equivalent to passing a hashref - + # stash is automatically passed to the view for use in a template $c->forward( 'MyApp::View::TT' ); @@ -475,7 +475,7 @@ sub _comp_prefixes { return $comp; } -# Find possible names for a prefix +# Find possible names for a prefix sub _comp_names { my ( $c, @prefixes ) = @_; @@ -547,7 +547,7 @@ Gets a L instance by name. Any extra arguments are directly passed to ACCEPT_CONTEXT. -If the name is omitted, it will look for +If the name is omitted, it will look for - a model object in $c->stash{current_model_instance}, then - a model name in $c->stash->{current_model}, then - a config setting 'default_model', or @@ -561,7 +561,7 @@ sub model { @args ) if $name; if (ref $c) { - return $c->stash->{current_model_instance} + return $c->stash->{current_model_instance} if $c->stash->{current_model_instance}; return $c->model( $c->stash->{current_model} ) if $c->stash->{current_model}; @@ -592,7 +592,7 @@ Gets a L instance by name. Any extra arguments are directly passed to ACCEPT_CONTEXT. -If the name is omitted, it will look for +If the name is omitted, it will look for - a view object in $c->stash{current_view_instance}, then - a view name in $c->stash->{current_view}, then - a config setting 'default_view', or @@ -606,7 +606,7 @@ sub view { @args ) if $name; if (ref $c) { - return $c->stash->{current_view_instance} + return $c->stash->{current_view_instance} if $c->stash->{current_view_instance}; return $c->view( $c->stash->{current_view} ) if $c->stash->{current_view}; @@ -871,7 +871,7 @@ You are running an old script! EOF } - + if ( $class->debug ) { my @plugins = map { "$_ " . ( $_->VERSION || '' ) } $class->registered_plugins; @@ -980,7 +980,7 @@ sub uri_for { } unshift(@args, $namespace || ''); } - + # join args with '/', or a blank string my $args = join('/', grep { defined($_) } @args); $args =~ s/\?/%3F/g; # STUPID STUPID SPECIAL CASE @@ -1151,7 +1151,7 @@ sub welcome_message {

In conclusion

-

The Catalyst team hopes you will enjoy using Catalyst as much +

The Catalyst team hopes you will enjoy using Catalyst as much as we enjoyed making it. Please contact us if you have ideas for improvement or other feedback.

@@ -1203,8 +1203,8 @@ that will be dumped on the error page in debug mode. sub dump_these { my $c = shift; - [ Request => $c->req ], - [ Response => $c->res ], + [ Request => $c->req ], + [ Response => $c->res ], [ Stash => $c->stash ], [ Config => $c->config ]; } @@ -1238,11 +1238,11 @@ sub execute { my $stats_info = $c->_stats_start_execute( $code ) if $c->use_stats; push( @{ $c->stack }, $code ); - + eval { $c->state( &$code( $class, $c, @{ $c->req->args } ) || 0 ) }; $c->_stats_finish_execute( $stats_info ) if $c->use_stats and $stats_info; - + my $last = pop( @{ $c->stack } ); if ( my $error = $@ ) { @@ -1297,7 +1297,7 @@ sub _stats_start_execute { # forward, locate the caller if ( my $parent = $c->stack->[-1] ) { $c->stats->profile( - begin => $action, + begin => $action, parent => "$parent" . $c->counter->{"$parent"}, uid => $uid, ); @@ -1312,7 +1312,7 @@ sub _stats_start_execute { } } else { - + # root-level call $c->stats->profile( begin => $action, @@ -1339,7 +1339,7 @@ sub _localize_fields { my $request = delete $localized->{request} || {}; my $response = delete $localized->{response} || {}; - + local @{ $c }{ keys %$localized } = values %$localized; local @{ $c->request }{ keys %$request } = values %$request; local @{ $c->response }{ keys %$response } = values %$response; @@ -1383,12 +1383,12 @@ sub finalize { $c->finalize_body; } - - if ($c->use_stats) { + + if ($c->use_stats) { my $elapsed = sprintf '%f', $c->stats->elapsed; my $av = $elapsed == 0 ? '??' : sprintf '%.3f', 1 / $elapsed; $c->log->info( - "Request took ${elapsed}s ($av/s)\n" . $c->stats->report . "\n" ); + "Request took ${elapsed}s ($av/s)\n" . $c->stats->report . "\n" ); } return $c->response->status; @@ -1539,7 +1539,7 @@ sub handle_request { my $c = $class->prepare(@arguments); $c->dispatch; - $status = $c->finalize; + $status = $c->finalize; }; if ( my $error = $@ ) { @@ -1600,7 +1600,7 @@ sub prepare { #surely this is not the most efficient way to do things... $c->stats($class->stats_class->new)->enable($c->use_stats); if ( $c->debug ) { - $c->res->headers->header( 'X-Catalyst' => $Catalyst::VERSION ); + $c->res->headers->header( 'X-Catalyst' => $Catalyst::VERSION ); } # For on-demand data @@ -1623,7 +1623,7 @@ sub prepare { # Prepare the body for reading, either by prepare_body # or the user, if they are using $c->read $c->prepare_read; - + # Parse the body unless the user wants it on-demand unless ( $c->config->{parse_on_demand} ) { $c->prepare_body; @@ -1891,9 +1891,9 @@ sub setup_components { my @paths = qw( ::Controller ::C ::Model ::M ::View ::V ); my $config = $class->config->{ setup_components }; my $extra = delete $config->{ search_extra } || []; - + push @paths, @$extra; - + my $locator = Module::Pluggable::Object->new( search_path => [ map { s/^(?=::)/$class/; $_; } @paths ], %$config @@ -1901,7 +1901,7 @@ sub setup_components { my @comps = sort { length $a <=> length $b } $locator->plugins; my %comps = map { $_ => 1 } @comps; - + for my $component ( @comps ) { # We pass ignore_loaded here so that overlay files for (e.g.) @@ -1916,11 +1916,11 @@ sub setup_components { $component => $module, map { $_ => $class->setup_component( $_ ) - } grep { + } grep { not exists $comps{$_} } Devel::InnerPackage::list_packages( $component ) ); - + for my $key ( keys %modules ) { $class->components->{ $key } = $modules{ $key }; } @@ -2177,7 +2177,7 @@ sub setup_stats { } -=head2 $c->registered_plugins +=head2 $c->registered_plugins Returns a sorted list of the plugins which have either been stated in the import list or which have been added via C<< MyApp->plugin(@args); >>. @@ -2314,7 +2314,7 @@ but if you want to handle input yourself, you can enable on-demand parsing with a config parameter. MyApp->config->{parse_on_demand} = 1; - + =head1 PROXY SUPPORT Many production servers operate using the common double-server approach, @@ -2328,9 +2328,9 @@ Catalyst will automatically detect this situation when you are running the frontend and backend servers on the same machine. The following changes are made to the request. - $c->req->address is set to the user's real IP address, as read from + $c->req->address is set to the user's real IP address, as read from the HTTP X-Forwarded-For header. - + The host value for $c->req->base and $c->req->uri is set to the real host, as read from the HTTP X-Forwarded-Host header. @@ -2342,7 +2342,7 @@ configuration option to tell Catalyst to read the proxied data from the headers. MyApp->config->{using_frontend_proxy} = 1; - + If you do not wish to use the proxy support at all, you may set: MyApp->config->{ignore_frontend_proxy} = 1; diff --git a/lib/Catalyst/Action.pm b/lib/Catalyst/Action.pm index a1e2e41..0e2bb58 100644 --- a/lib/Catalyst/Action.pm +++ b/lib/Catalyst/Action.pm @@ -10,7 +10,7 @@ Catalyst::Action - Catalyst Action =head1 DESCRIPTION -This class represents a Catalyst Action. You can access the object for the +This class represents a Catalyst Action. You can access the object for the currently dispatched action via $c->action. See the L for more information on how actions are dispatched. Actions are defined in L subclasses. diff --git a/lib/Catalyst/AttrContainer.pm b/lib/Catalyst/AttrContainer.pm index e83706b..334d5de 100644 --- a/lib/Catalyst/AttrContainer.pm +++ b/lib/Catalyst/AttrContainer.pm @@ -28,7 +28,7 @@ Catalyst::AttrContainer =head1 DESCRIPTION -This class sets up the code attribute cache. It's a base class for +This class sets up the code attribute cache. It's a base class for L. =head1 METHODS diff --git a/lib/Catalyst/Component.pm b/lib/Catalyst/Component.pm index 00ccfdd..aac0b64 100644 --- a/lib/Catalyst/Component.pm +++ b/lib/Catalyst/Component.pm @@ -31,7 +31,7 @@ Catalyst::Component - Catalyst Component Base Class my ( $self, $c ) = @_; $c->response->output( $self->{foo} ); } - + 1; # Methods can be a request step @@ -44,7 +44,7 @@ Catalyst::Component - Catalyst Component Base Class =head1 DESCRIPTION -This is the universal base class for Catalyst components +This is the universal base class for Catalyst components (Model/View/Controller). It provides you with a generic new() for instantiation through Catalyst's @@ -146,8 +146,8 @@ If this method is present (as it is on all Catalyst::Component subclasses, it is called by Catalyst during setup_components with the application class as $c and any config entry on the application for this component (for example, in the case of MyApp::Controller::Foo this would be -MyApp->config->{'Controller::Foo'}). The arguments are expected to be a -hashref and are merged with the __PACKAGE__->config hashref before calling +MyApp->config->{'Controller::Foo'}). The arguments are expected to be a +hashref and are merged with the __PACKAGE__->config hashref before calling ->new to instantiate the component. =head2 $c->config @@ -156,15 +156,15 @@ hashref and are merged with the __PACKAGE__->config hashref before calling =head2 $c->config($key, $value, ...) -Accessor for this component's config hash. Config values can be set as +Accessor for this component's config hash. Config values can be set as key value pair, or you can specify a hashref. In either case the keys -will be merged with any existing config settings. Each component in +will be merged with any existing config settings. Each component in a Catalyst application has it's own config hash. =head2 $c->process() This is the default method called on a Catalyst component in the dispatcher. -For instance, Views implement this action to render the response body +For instance, Views implement this action to render the response body when you forward to them. The default is an abstract method. =head2 $c->merge_config_hashes( $hashref, $hashref ) diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index 64fa368..2e58312 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -53,9 +53,9 @@ Catalyst::Controller - Catalyst Controller base class package MyApp::Controller::Search use base qw/Catalyst::Controller/; - sub foo : Local { + sub foo : Local { my ($self,$c,@args) = @_; - ... + ... } # Dispatches to /search/foo =head1 DESCRIPTION @@ -380,7 +380,7 @@ controller name. For instance controller 'MyApp::Controller::Foo::Bar' will be bound to 'foo/bar'. The default Root controller is an example of setting namespace to '' (the null string). -=head2 path +=head2 path Sets 'path_prefix', as described below. diff --git a/lib/Catalyst/DispatchType.pm b/lib/Catalyst/DispatchType.pm index b368473..dcc442f 100644 --- a/lib/Catalyst/DispatchType.pm +++ b/lib/Catalyst/DispatchType.pm @@ -14,7 +14,7 @@ See L. =head1 DESCRIPTION -This is an abstract base class for Dispatch Types. +This is an abstract base class for Dispatch Types. =head1 METHODS @@ -39,7 +39,7 @@ sub match { die "Abstract method!" } =head2 $self->register( $c, $action ) abstract method, to be implemented by dispatchtypes. Takes a -context object and a L object. +context object and a L object. Should return true if it registers something, or false otherwise. diff --git a/lib/Catalyst/DispatchType/Chained.pm b/lib/Catalyst/DispatchType/Chained.pm index 267240d..1b8219a 100644 --- a/lib/Catalyst/DispatchType/Chained.pm +++ b/lib/Catalyst/DispatchType/Chained.pm @@ -198,7 +198,7 @@ sub recurse_match { # No best action currently # OR This one matches with fewer parts left than the current best action, # And therefore is a better match - # OR No parts and this expects 0 + # OR No parts and this expects 0 # The current best action might also be Args(0), # but we couldn't chose between then anyway so we'll take the last seen @@ -325,7 +325,7 @@ sub uri_for_action { return undef if @captures; # fail for too many captures return join('/', '', @parts); - + } __PACKAGE__->meta->make_immutable; @@ -488,7 +488,7 @@ this debugging output: '-----------------------+------------------------------' ... -Here's a more detailed specification of the attributes belonging to +Here's a more detailed specification of the attributes belonging to C<:Chained>: =head2 Attributes diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 86ac3b9..e735cf0 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -51,7 +51,7 @@ application based on the attributes you set. =head1 METHODS -=head2 new +=head2 new Construct a new dispatcher. @@ -306,9 +306,9 @@ sub get_action { return $self->_action_hash->{"${namespace}/${name}"}; } -=head2 $self->get_action_by_path( $path ); +=head2 $self->get_action_by_path( $path ); -Returns the named action by its full path. +Returns the named action by its full path. =cut diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 1f22735..2de21bd 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -243,7 +243,7 @@ EOF } /* from http://users.tkk.fi/~tkarvine/linux/doc/pre-wrap/pre-wrap-css3-mozilla-opera-ie.html */ /* Browser specific (not valid) styles to make preformatted text wrap */ - pre { + pre { white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ @@ -317,7 +317,7 @@ sub prepare_body { $request->{_body}->{tmpdir} = $c->config->{uploadtmp} if exists $c->config->{uploadtmp}; } - + while ( my $buffer = $self->read($c) ) { $c->prepare_body_chunk($buffer); } @@ -350,15 +350,15 @@ sub prepare_body_chunk { =head2 $self->prepare_body_parameters($c) -Sets up parameters from body. +Sets up parameters from body. =cut sub prepare_body_parameters { my ( $self, $c ) = @_; - + return unless $c->request->{_body}; - + $c->request->body_parameters( $c->request->{_body}->param ); } @@ -436,7 +436,7 @@ process the query string and extract query parameters. sub prepare_query_parameters { my ( $self, $c, $query_string ) = @_; - + # Check for keywords (no = signs) # (yes, index() is faster than a regex :)) if ( index( $query_string, '=' ) < 0 ) { @@ -448,17 +448,17 @@ sub prepare_query_parameters { # replace semi-colons $query_string =~ s/;/&/g; - + my @params = split /&/, $query_string; for my $item ( @params ) { - - my ($param, $value) + + my ($param, $value) = map { $self->unescape_uri($_) } split( /=/, $item, 2 ); - + $param = $self->unescape_uri($item) unless defined $param; - + if ( exists $query{$param} ) { if ( ref $query{$param} ) { push @{ $query{$param} }, $value; @@ -486,7 +486,7 @@ sub prepare_read { # Initialize the read position $self->read_position(0); - + # Initialize the amount of data we think we need to read $self->read_length( $c->request->header('Content-Length') || 0 ); } @@ -619,15 +619,15 @@ sub write { $self->prepare_write($c); $self->{_prepared_write} = 1; } - + my $len = length($buffer); my $wrote = syswrite STDOUT, $buffer; - + if ( !defined $wrote && $! == EWOULDBLOCK ) { # Unable to write on the first try, will retry in the loop below $wrote = 0; } - + if ( defined $wrote && $wrote < $len ) { # We didn't write the whole buffer while (1) { @@ -639,11 +639,11 @@ sub write { next if $! == EWOULDBLOCK; return; } - + last if $wrote >= $len; } } - + return $wrote; } diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index 75b8fba..ae5a652 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -41,7 +41,7 @@ sub finalize_headers { $c->response->header( Status => $c->response->status ); - $self->{_header_buf} + $self->{_header_buf} = $c->response->headers->as_string("\015\012") . "\015\012"; } @@ -139,21 +139,21 @@ sub prepare_path { # set the request URI my $path = $base_path . ( $ENV{PATH_INFO} || '' ); $path =~ s{^/+}{}; - + # Using URI directly is way too slow, so we construct the URLs manually my $uri_class = "URI::$scheme"; - + # HTTP_HOST will include the port even if it's 80/443 $host =~ s/:(?:80|443)$//; - + if ( $port !~ /^(?:80|443)$/ && $host !~ /:/ ) { $host .= ":$port"; } - + # Escape the path $path =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go; $path =~ s/\?/%3F/g; # STUPID STUPID SPECIAL CASE - + my $query = $ENV{QUERY_STRING} ? '?' . $ENV{QUERY_STRING} : ''; my $uri = $scheme . '://' . $host . '/' . $path . $query; @@ -162,7 +162,7 @@ sub prepare_path { # set the base URI # base must end in a slash $base_path .= '/' unless $base_path =~ m{/$}; - + my $base_uri = $scheme . '://' . $host . $base_path; $c->request->base( bless \$base_uri, $uri_class ); diff --git a/lib/Catalyst/Engine/FastCGI.pm b/lib/Catalyst/Engine/FastCGI.pm index 8e59958..e009dfa 100644 --- a/lib/Catalyst/Engine/FastCGI.pm +++ b/lib/Catalyst/Engine/FastCGI.pm @@ -19,7 +19,7 @@ This is the FastCGI engine. This class overloads some methods from C. =head2 $self->run($c, $listen, { option => value, ... }) - + Starts the FastCGI server. If C<$listen> is set, then it specifies a location to listen for FastCGI requests; @@ -61,7 +61,7 @@ Specify a filename for the pid file Specify a FCGI::ProcManager sub-class -=item detach +=item detach Detach from console @@ -99,7 +99,7 @@ sub run { my $error = \*STDERR; # send STDERR to the web server $error = \*STDOUT # send STDERR to stdout (a logfile) if $options->{keep_stderr}; # (if asked to) - + my $request = FCGI::Request( \*STDIN, \*STDOUT, $error, \%env, $sock, ( $options->{nointr} ? 0 : &FCGI::FAIL_ACCEPT_ON_INTR ), @@ -135,16 +135,16 @@ sub run { while ( $request->Accept >= 0 ) { $proc_manager && $proc_manager->pm_pre_dispatch(); - + # If we're running under Lighttpd, swap PATH_INFO and SCRIPT_NAME # http://lists.rawmode.org/pipermail/catalyst/2006-June/008361.html # Thanks to Mark Blythe for this fix if ( $env{SERVER_SOFTWARE} && $env{SERVER_SOFTWARE} =~ /lighttpd/ ) { $env{PATH_INFO} ||= delete $env{SCRIPT_NAME}; } - + $class->handle_request( env => \%env ); - + $proc_manager && $proc_manager->pm_post_dispatch(); } } @@ -160,11 +160,11 @@ sub write { $self->prepare_write($c); $self->{_prepared_write} = 1; } - + # XXX: We can't use Engine's write() method because syswrite # appears to return bogus values instead of the number of bytes # written: http://www.fastcgi.com/om_archive/mail-archive/0128.html - + # Prepend the headers if they have not yet been sent if ( my $headers = delete $self->{_header_buf} ) { $buffer = $headers . $buffer; @@ -215,7 +215,7 @@ __END__ =head2 Standalone FastCGI Server -In server mode the application runs as a standalone server and accepts +In server mode the application runs as a standalone server and accepts connections from a web server. The application can be on the same machine as the web server, on a remote machine, or even on multiple remote machines. Advantages of this method include running the Catalyst application as a @@ -226,14 +226,14 @@ To start your application in server mode, install the FCGI::ProcManager module and then use the included fastcgi.pl script. $ script/myapp_fastcgi.pl -l /tmp/myapp.socket -n 5 - + Command line options for fastcgi.pl include: -d -daemon Daemonize the server. -p -pidfile Write a pidfile with the pid of the process manager. -l -listen Listen on a socket path, hostname:port, or :port. -n -nproc The number of processes started to handle requests. - + See below for the specific web server configurations for using the external server. @@ -242,20 +242,20 @@ server. Apache requires the mod_fastcgi module. The same module supports both Apache 1 and 2. -There are three ways to run your application under FastCGI on Apache: server, +There are three ways to run your application under FastCGI on Apache: server, static, and dynamic. =head3 Standalone server mode FastCgiExternalServer /tmp/myapp.fcgi -socket /tmp/myapp.socket Alias /myapp/ /tmp/myapp/myapp.fcgi/ - + # Or, run at the root Alias / /tmp/myapp.fcgi/ - + # Optionally, rewrite the path when accessed without a trailing slash RewriteRule ^/myapp$ myapp/ [R] - + The FastCgiExternalServer directive tells Apache that when serving /tmp/myapp to use the FastCGI application listenting on the socket @@ -264,7 +264,7 @@ it's a virtual file name. With some versions of C or C, you can use any name you like, but most require that the virtual filename end in C<.fcgi>. -It's likely that Apache is not configured to serve files in /tmp, so the +It's likely that Apache is not configured to serve files in /tmp, so the Alias directive maps the url path /myapp/ to the (virtual) file that runs the FastCGI application. The trailing slashes are important as their use will correctly set the PATH_INFO environment variable used by Catalyst to @@ -282,14 +282,14 @@ FastCGI script to run your application. FastCgiServer /path/to/myapp/script/myapp_fastcgi.pl -processes 3 Alias /myapp/ /path/to/myapp/script/myapp_fastcgi.pl/ - + FastCgiServer tells Apache to start three processes of your application at startup. The Alias command maps a path to the FastCGI application. Again, the trailing slashes are important. - + =head3 Dynamic mode -In FastCGI dynamic mode, Apache will run your application on demand, +In FastCGI dynamic mode, Apache will run your application on demand, typically by requesting a file with a specific extension (e.g. .fcgi). ISPs often use this type of setup to provide FastCGI support to many customers. @@ -321,7 +321,7 @@ Here is a complete example: Then a request for /script/myapp_fastcgi.pl will run the application. - + For more information on using FastCGI under Apache, visit L @@ -355,7 +355,7 @@ These configurations were tested with Lighttpd 1.4.7. =head3 Static mode server.document-root = "/var/www/MyApp/root" - + fastcgi.server = ( "" => ( "MyApp" => ( @@ -368,12 +368,12 @@ These configurations were tested with Lighttpd 1.4.7. ) ) ) - + Note that in newer versions of lighttpd, the min-procs and idle-timeout values are disabled. The above example would start 5 processes. =head3 Non-root configuration - + You can also run your application at any non-root location with either of the above modes. diff --git a/lib/Catalyst/Engine/HTTP.pm b/lib/Catalyst/Engine/HTTP.pm index 30c5201..090b4f2 100644 --- a/lib/Catalyst/Engine/HTTP.pm +++ b/lib/Catalyst/Engine/HTTP.pm @@ -61,8 +61,8 @@ sub finalize_headers { # Should we keep the connection open? my $connection = $c->request->header('Connection'); - if ( $self->{options}->{keepalive} - && $connection + if ( $self->{options}->{keepalive} + && $connection && $connection =~ /^keep-alive$/i ) { $res_headers->header( Connection => 'keep-alive' ); @@ -105,7 +105,7 @@ befpre prepare_read => sub { sub read_chunk { my $self = shift; my $c = shift; - + # If we have any remaining data in the input buffer, send it back first if ( $_[0] = delete $self->{inputbuf} ) { my $read = length( $_[0] ); @@ -159,7 +159,7 @@ around write => sub { else { DEBUG && warn "write: Wrote response ($ret bytes)\n"; } - + return $ret; }; @@ -172,7 +172,7 @@ sub run { my ( $self, $class, $port, $host, $options ) = @_; $options ||= {}; - + $self->{options} = $options; if ($options->{background}) { @@ -276,10 +276,10 @@ sub run { } $self->_handler( $class, $port, $method, $uri, $protocol ); - + if ( my $error = delete $self->{_write_error} ) { close Remote; - + if ( !defined $pid ) { next LISTEN; } @@ -311,9 +311,9 @@ sub run { close Remote; } } - + $daemon->close; - + DEBUG && warn "Shutting down\n"; if ($restart) { @@ -324,8 +324,8 @@ sub run { ### those include dirs upon re-exec. So add them to PERL5LIB, so they ### are available again for the exec'ed process --kane use Config; - $ENV{PERL5LIB} .= join $Config{path_sep}, @INC; - + $ENV{PERL5LIB} .= join $Config{path_sep}, @INC; + exec $^X, $0, @{ $options->{argv} }; } @@ -346,11 +346,11 @@ sub _handler { my $sel = IO::Select->new; $sel->add( \*STDIN ); - + REQUEST: while (1) { my ( $path, $query_string ) = split /\?/, $uri, 2; - + # Initialize CGI environment local %ENV = ( PATH_INFO => $path || '', @@ -371,37 +371,37 @@ sub _handler { # Pass flow control to Catalyst $class->handle_request; - + DEBUG && warn "Request done\n"; - + # Allow keepalive requests, this is a hack but we'll support it until # the next major release. if ( delete $self->{_keepalive} ) { - + DEBUG && warn "Reusing previous connection for keep-alive request\n"; - - if ( $sel->can_read(1) ) { + + if ( $sel->can_read(1) ) { if ( !$self->_read_headers ) { # Error reading, give up last REQUEST; } ( $method, $uri, $protocol ) = $self->_parse_request_line; - + DEBUG && warn "Parsed request: $method $uri $protocol\n"; - + # Force HTTP/1.0 $protocol = '1.0'; - + next REQUEST; } - + DEBUG && warn "No keep-alive request within 1 second\n"; } - + last REQUEST; } - + DEBUG && warn "Closing connection\n"; close Remote; @@ -472,19 +472,19 @@ sub _parse_headers { } } $headers->push_header( $key, $val ) if $key; - + DEBUG && warn "Parsed headers: " . dump($headers) . "\n"; # Convert headers into ENV vars $headers->scan( sub { my ( $key, $val ) = @_; - + $key = uc $key; $key = 'COOKIE' if $key eq 'COOKIES'; $key =~ tr/-/_/; $key = 'HTTP_' . $key unless $key =~ m/\A(?:CONTENT_(?:LENGTH|TYPE)|COOKIE)\z/; - + if ( exists $ENV{$key} ) { $ENV{$key} .= ", $val"; } @@ -498,19 +498,19 @@ sub _socket_data { my ( $self, $handle ) = @_; my $remote_sockaddr = getpeername($handle); - my ( undef, $iaddr ) = $remote_sockaddr - ? sockaddr_in($remote_sockaddr) + my ( undef, $iaddr ) = $remote_sockaddr + ? sockaddr_in($remote_sockaddr) : (undef, undef); - + my $local_sockaddr = getsockname($handle); my ( undef, $localiaddr ) = sockaddr_in($local_sockaddr); # This mess is necessary to keep IE from crashing the server my $data = { - peername => $iaddr + peername => $iaddr ? ( gethostbyaddr( $iaddr, AF_INET ) || 'localhost' ) : 'localhost', - peeraddr => $iaddr + peeraddr => $iaddr ? ( inet_ntoa($iaddr) || '127.0.0.1' ) : '127.0.0.1', localname => gethostbyaddr( $localiaddr, AF_INET ) || 'localhost', diff --git a/lib/Catalyst/Engine/HTTP/Restarter.pm b/lib/Catalyst/Engine/HTTP/Restarter.pm index 8e5c8c0..a410950 100644 --- a/lib/Catalyst/Engine/HTTP/Restarter.pm +++ b/lib/Catalyst/Engine/HTTP/Restarter.pm @@ -18,8 +18,8 @@ around run => sub { close STDOUT; my $watcher = Catalyst::Engine::HTTP::Restarter::Watcher->new( - directory => ( - $options->{restart_directory} || + directory => ( + $options->{restart_directory} || File::Spec->catdir( $FindBin::Bin, '..' ) ), follow_symlinks => $options->{follow_symlinks}, diff --git a/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm b/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm index b1ae9b7..847fb0d 100644 --- a/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm +++ b/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm @@ -44,7 +44,7 @@ sub watch { my @changes; my @changed_files; - + my $delay = ( defined $self->delay ) ? $self->delay : 1; sleep $delay if $delay > 0; @@ -156,7 +156,7 @@ files regex => '\.yml$|\.yaml$|\.pm$', delay => 1, ); - + while (1) { my @changed_files = $watcher->watch(); } diff --git a/lib/Catalyst/Log.pm b/lib/Catalyst/Log.pm index c1ba85a..1314ceb 100644 --- a/lib/Catalyst/Log.pm +++ b/lib/Catalyst/Log.pm @@ -215,8 +215,8 @@ Is the log level active? =head2 abort -Should Catalyst emit logs for this request? Will be reset at the end of -each request. +Should Catalyst emit logs for this request? Will be reset at the end of +each request. *NOTE* This method is not compatible with other log apis, so if you plan to use Log4Perl or another logger, you should call it like this: diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index dfec6d0..e5dcc85 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -301,7 +301,7 @@ Contains the keywords portion of a query string, when no '=' signs are present. http://localhost/path?some+keywords - + $c->request->query_keywords will contain 'some keywords' =head2 $req->match @@ -316,7 +316,7 @@ Contains the request method (C, C, C, etc). =head2 $req->param -Returns GET and POST parameters with a CGI.pm-compatible param method. This +Returns GET and POST parameters with a CGI.pm-compatible param method. This is an alternative method for accessing parameters in $c->req->parameters. $value = $c->request->param( 'foo' ); @@ -425,7 +425,7 @@ be either a scalar or an arrayref containing scalars. print $c->request->query_parameters->{field}; print $c->request->query_parameters->{field}->[0]; - + =head2 $req->read( [$maxlength] ) Reads a chunk of data from the request body. This method is intended to be @@ -518,7 +518,7 @@ sub upload { =head2 $req->uploads Returns a reference to a hash containing uploads. Values can be either a -L object, or an arrayref of +L object, or an arrayref of L objects. my $upload = $c->request->uploads->{field}; @@ -538,7 +538,7 @@ preserved. sub uri_with { my( $self, $args ) = @_; - + carp( 'No arguments passed to uri_with()' ) unless $args; for my $value ( values %$args ) { @@ -548,9 +548,9 @@ sub uri_with { utf8::encode( $_ ) if utf8::is_utf8($_); } }; - + my $uri = $self->uri->clone; - + $uri->query_form( { %{ $uri->query_form_hash }, %$args diff --git a/lib/Catalyst/Request/Upload.pm b/lib/Catalyst/Request/Upload.pm index 02848b2..59168d0 100644 --- a/lib/Catalyst/Request/Upload.pm +++ b/lib/Catalyst/Request/Upload.pm @@ -101,7 +101,7 @@ Returns an L object for the request. =head2 $upload->link_to -Creates a hard link to the temporary file. Returns true for success, +Creates a hard link to the temporary file. Returns true for success, false for failure. $upload->link_to('/path/to/target'); diff --git a/lib/Catalyst/Response.pm b/lib/Catalyst/Response.pm index 3b57cab..cb280dd 100644 --- a/lib/Catalyst/Response.pm +++ b/lib/Catalyst/Response.pm @@ -84,7 +84,7 @@ The keys of the hash reference on the right correspond to the L parameters of the same name, except they are used without a leading dash. Possible parameters are: -=over +=over =item value @@ -144,7 +144,7 @@ Sets or returns the HTTP 'Location'. Sets or returns the HTTP status. $c->response->status(404); - + =head2 $res->write( $data ) Writes $data to the output stream. @@ -165,7 +165,7 @@ Marcus Ramberg, C =head1 COPYRIGHT -This program is free software, you can redistribute it and/or modify +This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut diff --git a/lib/Catalyst/Stats.pm b/lib/Catalyst/Stats.pm index 5fadca6..0c39915 100644 --- a/lib/Catalyst/Stats.pm +++ b/lib/Catalyst/Stats.pm @@ -118,7 +118,7 @@ sub _get_uid { $visitor->searchForUID($uid); $self->tree->accept($visitor); return $visitor->getResult; -} +} 1; @@ -168,7 +168,7 @@ be like this: $c->stats->profile("completed second part of critical bit"); # more code ... - $c->stats->profile(end => "mysub"); + $c->stats->profile(end => "mysub"); } Supposing mysub was called from the action "process" inside a Catalyst @@ -195,7 +195,7 @@ part 0.111s. =head2 new -Constructor. +Constructor. $stats = Catalyst::Stats->new; @@ -214,7 +214,7 @@ Enable or disable stats collection. By default, stats are enabled after object Marks a profiling point. These can appear in pairs, to time the block of code between the begin/end pairs, or by themselves, in which case the time of -execution to the previous profiling point will be reported. +execution to the previous profiling point will be reported. The argument may be either a single comment string or a list of name-value pairs. Thus the following are equivalent: diff --git a/lib/Catalyst/View.pm b/lib/Catalyst/View.pm index f4e8cad..29964b9 100644 --- a/lib/Catalyst/View.pm +++ b/lib/Catalyst/View.pm @@ -19,15 +19,15 @@ Catalyst::View - Catalyst View base class =head1 DESCRIPTION -This is the Catalyst View base class. It's meant to be used as +This is the Catalyst View base class. It's meant to be used as a base class by Catalyst views. -As a convention, views are expected to read template names from +As a convention, views are expected to read template names from $c->stash->{template}, and put the output into $c->res->body. Some views default to render a template named after the dispatched action's private name. (See L.) -=head1 METHODS +=head1 METHODS Implements the same methods as other Catalyst components, see L diff --git a/t/c3_mro.t b/t/c3_mro.t index 32ba3b0..b4bc0a7 100644 --- a/t/c3_mro.t +++ b/t/c3_mro.t @@ -13,7 +13,7 @@ my @cat_mods; { local @INC = grep {/blib/} @INC; @cat_mods = ( - 'Catalyst', + 'Catalyst', Module::Pluggable::Object->new(search_path => ['Catalyst'])->plugins, ); } diff --git a/t/lib/Catalyst/Plugin/Test/Errors.pm b/t/lib/Catalyst/Plugin/Test/Errors.pm index f5212e3..b040b1c 100644 --- a/t/lib/Catalyst/Plugin/Test/Errors.pm +++ b/t/lib/Catalyst/Plugin/Test/Errors.pm @@ -13,10 +13,10 @@ sub error { if ( $_[0] =~ /^(Unknown resource|No default action defined)/ ) { $c->response->status(404); } - + if ( $_[0] =~ /^Couldn\'t forward/ ) { $c->response->status(404); - } + } if ( $_[0] =~ /^Caught exception/ ) { $c->response->status(500); diff --git a/t/lib/Catalyst/Plugin/Test/Headers.pm b/t/lib/Catalyst/Plugin/Test/Headers.pm index 5bb07a5..0258a09 100644 --- a/t/lib/Catalyst/Plugin/Test/Headers.pm +++ b/t/lib/Catalyst/Plugin/Test/Headers.pm @@ -10,7 +10,7 @@ sub prepare { $c->response->header( 'X-Catalyst-Engine' => $c->engine ); $c->response->header( 'X-Catalyst-Debug' => $c->debug ? 1 : 0 ); - + { my $components = join( ', ', sort keys %{ $c->components } ); $c->response->header( 'X-Catalyst-Components' => $components ); diff --git a/t/unit_core_component_loading.t b/t/unit_core_component_loading.t index bae3c5e..2587385 100644 --- a/t/unit_core_component_loading.t +++ b/t/unit_core_component_loading.t @@ -40,7 +40,7 @@ my @components = ( { type => 'View', prefix => 'View', name => 'Foo' }, ); -sub write_component_file { +sub write_component_file { my ($dir_list, $module_name, $content) = @_; my $dir = File::Spec->catdir(@$dir_list); @@ -165,7 +165,7 @@ write_component_file([$libdir, $appclass, 'Model'], 'TopLevel', <NEXT::COMPONENT(\@_); no strict 'refs'; *{\__PACKAGE__ . "::whoami"} = sub { return \__PACKAGE__; };