X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=750f3fe1be205a5518cf798bf30561bafc92a8d7;hb=c4695f3aa02151dcd257c01cdee3f70cfa2e5888;hp=4b7fad7a4bf3d4a15bf908e9f2c03e19c761bfb5;hpb=6dc87a0f8301391acfe25ee5bcaad0fe48dad559;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 4b7fad7..750f3fe 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -161,111 +161,25 @@ sub finalize { $c->finalize_cookies; - if ( my $location = $c->res->redirect ) { + if ( my $location = $c->response->redirect ) { $c->log->debug(qq/Redirecting to "$location"/) if $c->debug; $c->response->header( Location => $location ); - $c->response->status(302); - } - - if ( $c->res->status =~ /^(1\d\d|[23]04)$/ ) { - $c->response->headers->remove_content_headers; - return $c->finalize_headers; - } - - if ( !$c->res->output || $#{ $c->error } >= 0 ) { - $c->res->headers->content_type('text/html'); - my $name = $c->config->{name} || 'Catalyst Application'; - my ( $title, $error, $infos ); - if ( $c->debug ) { - $error = join '
', @{ $c->error }; - $error ||= 'No output'; - $title = $name = "$name on Catalyst $Catalyst::VERSION"; - my $req = encode_entities Dumper $c->req; - my $res = encode_entities Dumper $c->res; - my $stash = encode_entities Dumper $c->stash; - $infos = <<""; -
-Request
-
$req
-Response
-
$res
-Stash
-
$stash
+ $c->response->status(302) if $c->response->status !~ /3\d\d$/; + } - } - else { - $title = $name; - $error = ''; - $infos = <<""; -
-(en) Please come back later
-(de) Bitte versuchen sie es spaeter nocheinmal
-(nl) Gelieve te komen later terug
-(no) Vennligst prov igjen senere
-(fr) Veuillez revenir plus tard
-(es) Vuelto por favor mas adelante
-(pt) Voltado por favor mais tarde
-(it) Ritornato prego più successivamente
-
+ if ( $#{ $c->error } >= 0 ) { + $c->finalize_error; + } - $name = ''; - } - $c->res->{output} = <<""; - - - $title - - - -
-
$error
-
$infos
-
$name
-
- - + if ( !$c->response->output && $c->response->status !~ /^(1|3)\d\d$/ ) { + $c->finalize_error; + } + if ( $c->response->output && !$c->response->content_length ) { + use bytes; # play safe with a utf8 aware perl + $c->response->content_length( length $c->response->output ); } - $c->res->headers->content_length( length $c->res->output ); + my $status = $c->finalize_headers; $c->finalize_output; return $status; @@ -294,6 +208,109 @@ sub finalize_cookies { } } +=item $c->finalize_error + +Finalize error. + +=cut + +sub finalize_error { + my $c = shift; + + $c->res->headers->content_type('text/html'); + my $name = $c->config->{name} || 'Catalyst Application'; + + my ( $title, $error, $infos ); + if ( $c->debug ) { + $error = join '
', @{ $c->error }; + $error ||= 'No output'; + $title = $name = "$name on Catalyst $Catalyst::VERSION"; + my $req = encode_entities Dumper $c->req; + my $res = encode_entities Dumper $c->res; + my $stash = encode_entities Dumper $c->stash; + $infos = <<""; +
+Request
+
$req
+Response
+
$res
+Stash
+
$stash
+ + } + else { + $title = $name; + $error = ''; + $infos = <<""; +
+(en) Please come back later
+(de) Bitte versuchen sie es spaeter nocheinmal
+(nl) Gelieve te komen later terug
+(no) Vennligst prov igjen senere
+(fr) Veuillez revenir plus tard
+(es) Vuelto por favor mas adelante
+(pt) Voltado por favor mais tarde
+(it) Ritornato prego più successivamente
+
+ + $name = ''; + } + $c->res->output( <<"" ); + + + $title + + + +
+
$error
+
$infos
+
$name
+
+ + + +} + =item $c->finalize_headers Finalize headers.