X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=d45896239c4256a80a716fc303dcaa9fb7abd258;hb=41aaa5d65dfd130dd0376d3fa41a3f2ab78c066a;hp=3a8e5c38a7205408793e6abfd467924c505fb298;hpb=684ca75d81f91dc5302f1654d7029c93be4f5a37;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 3a8e5c3..d458962 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -50,13 +50,20 @@ has request => ( is => 'rw', default => sub { my $self = shift; - my %p; + my %p = ( _log => $self->log ); $p{_uploadtmp} = $self->_uploadtmp if $self->_has_uploadtmp; $self->request_class->new(\%p); }, lazy => 1, ); -has response => (is => 'rw', default => sub { $_[0]->response_class->new({}) }, required => 1, lazy => 1); +has response => ( + is => 'rw', + default => sub { + my $self = shift; + $self->response_class->new({ _log => $self->log }); + }, + lazy => 1, +); has namespace => (is => 'rw'); sub depth { scalar @{ shift->stack || [] }; } @@ -2008,9 +2015,6 @@ sub prepare { my $uploadtmp = $class->config->{uploadtmp}; my $c = $class->context_class->new({ $uploadtmp ? (_uploadtmp => $uploadtmp) : ()}); - # For on-demand data - $c->request->_context($c); - #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->config->{enable_catalyst_header} ) { @@ -2026,6 +2030,8 @@ sub prepare { $c->prepare_request(@arguments); $c->prepare_connection; $c->prepare_query_parameters; + $c->prepare_headers; # Just hooks, no longer needed - they just + $c->prepare_cookies; # cause the lazy attribute on req to build $c->prepare_path; # Prepare the body for reading, either by prepare_body @@ -2122,6 +2128,24 @@ sub prepare_connection { $c->engine->prepare_connection($c); } +=head2 $c->prepare_cookies + +Prepares cookies by ensuring that the attribute on the request +object has been built. + +=cut + +sub prepare_cookies { my $c = shift; $c->request->cookies } + +=head2 $c->prepare_headers + +Prepares request headers by ensuring that the attribute on the request +object has been built. + +=cut + +sub prepare_headers { my $c = shift; $c->request->headers } + =head2 $c->prepare_parameters Prepares parameters. @@ -2972,6 +2996,9 @@ your output data, if known. sub write { my $c = shift; + # Finalize headers if someone manually writes output (for compat) + $c->finalize_headers; + return $c->response->write( @_ ); }