X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=0b2c012e86790881ad42245eaf47f0066230a7a9;hb=051a69b9ac0e94a03b8e95ee3fdf8e989b635725;hp=d40b2a5a710a510a6e649fd7fefcdb123466bea2;hpb=c7250231c0125c7c763ab9c8b7655e099cf6a1de;p=catagits%2FCatalyst-Runtime.git
diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm
index d40b2a5..0b2c012 100644
--- a/lib/Catalyst.pm
+++ b/lib/Catalyst.pm
@@ -4,7 +4,7 @@ use Moose;
use Moose::Meta::Class ();
extends 'Catalyst::Component';
use Moose::Util qw/find_meta/;
-use B::Hooks::EndOfScope ();
+use namespace::clean -except => 'meta';
use Catalyst::Exception;
use Catalyst::Exception::Detach;
use Catalyst::Exception::Go;
@@ -23,6 +23,7 @@ use Path::Class::File ();
use URI ();
use URI::http;
use URI::https;
+use HTML::Entities;
use Tree::Simple qw/use_weak_refs/;
use Tree::Simple::Visitor::FindByUID;
use Class::C3::Adopt::NEXT;
@@ -33,12 +34,14 @@ use Catalyst::EngineLoader;
use utf8;
use Carp qw/croak carp shortmess/;
use Try::Tiny;
+use Safe::Isa;
use Plack::Middleware::Conditional;
use Plack::Middleware::ReverseProxy;
use Plack::Middleware::IIS6ScriptNameFix;
+use Plack::Middleware::IIS7KeepAliveFix;
use Plack::Middleware::LighttpdScriptNameFix;
-BEGIN { require 5.008004; }
+BEGIN { require 5.008003; }
has stack => (is => 'ro', default => sub { [] });
has stash => (is => 'rw', default => sub { {} });
@@ -46,8 +49,34 @@ has state => (is => 'rw', default => 0);
has stats => (is => 'rw');
has action => (is => 'rw');
has counter => (is => 'rw', default => sub { {} });
-has request => (is => 'rw', default => sub { $_[0]->request_class->new({}) }, required => 1, lazy => 1);
-has response => (is => 'rw', default => sub { $_[0]->response_class->new({}) }, required => 1, lazy => 1);
+has request => (
+ is => 'rw',
+ default => sub {
+ my $self = shift;
+ $self->request_class->new($self->_build_request_constructor_args);
+ },
+ lazy => 1,
+);
+sub _build_request_constructor_args {
+ my $self = shift;
+ my %p = ( _log => $self->log );
+ $p{_uploadtmp} = $self->_uploadtmp if $self->_has_uploadtmp;
+ \%p;
+}
+
+has response => (
+ is => 'rw',
+ default => sub {
+ my $self = shift;
+ $self->response_class->new($self->_build_response_constructor_args);
+ },
+ lazy => 1,
+);
+sub _build_response_constructor_args {
+ my $self = shift;
+ { _log => $self->log };
+}
+
has namespace => (is => 'rw');
sub depth { scalar @{ shift->stack || [] }; }
@@ -84,7 +113,7 @@ __PACKAGE__->stats_class('Catalyst::Stats');
# Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.90005';
+our $VERSION = '5.90019';
sub import {
my ( $class, @arguments ) = @_;
@@ -119,6 +148,8 @@ sub import {
sub _application { $_[0] }
+=encoding UTF-8
+
=head1 NAME
Catalyst - The Elegant MVC Web Application Framework
@@ -356,8 +387,12 @@ When called with no arguments it escapes the processing chain entirely.
sub detach { my $c = shift; $c->dispatcher->detach( $c, @_ ) }
+=head2 $c->visit( $action [, \@arguments ] )
+
=head2 $c->visit( $action [, \@captures, \@arguments ] )
+=head2 $c->visit( $class, $method, [, \@arguments ] )
+
=head2 $c->visit( $class, $method, [, \@captures, \@arguments ] )
Almost the same as L<< forward|/"$c->forward( $action [, \@arguments ] )" >>,
@@ -386,8 +421,12 @@ transfer control to another action as if it had been reached directly from a URL
sub visit { my $c = shift; $c->dispatcher->visit( $c, @_ ) }
+=head2 $c->go( $action [, \@arguments ] )
+
=head2 $c->go( $action [, \@captures, \@arguments ] )
+=head2 $c->go( $class, $method, [, \@arguments ] )
+
=head2 $c->go( $class, $method, [, \@captures, \@arguments ] )
The relationship between C
If you want to jump right into web development with Catalyst you might want to start with a tutorial.
-perldoc Catalyst::Manual::Tutorial +perldoc Catalyst::Manual::TutorialAfterwards you can go on to check out a more complete look at our features.
-perldoc Catalyst::Manual::Intro +
perldoc Catalyst::Manual::Intro
What to do next?
Next it's time to write an actual application. Use the - helper scripts to generate controllers, - models, and - views; + helper scripts to generate controllers, + models, and + views; they can save you a lot of work.
script/${prefix}_create.pl --help
Also, be sure to check out the vast and growing @@ -1576,7 +1592,7 @@ EOF =head2 run_options Contains a hash of options passed from the application script, including -the original ARGV the script receieved, the processed values from that +the original ARGV the script received, the processed values from that ARGV and any extra arguments to the script which were not processed. This can be used to add custom options to your application's scripts @@ -1787,7 +1803,7 @@ sub finalize { $c->finalize_error; } - $c->finalize_headers; + $c->finalize_headers unless $c->response->finalized_headers; # HEAD request if ( $c->request->method eq 'HEAD' ) { @@ -1854,6 +1870,7 @@ sub finalize_headers { if ( !$response->has_body ) { # Add a default body if none is already present + my $encoded_location = encode_entities($location); $response->body(<<"EOF"); @@ -1861,7 +1878,7 @@ sub finalize_headers {
Moved -This item has moved here.
+This item has moved here.