Skip to content

Commit

Permalink
handle advice more consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 26, 2014
1 parent 18fb677 commit 9f3bb31
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions lib/Mojolicious.pm
Expand Up @@ -111,9 +111,7 @@ sub dispatch {

# Routes
$plugins->emit_hook(before_routes => $c);
my $res = $tx->res;
return if $res->code;
if (my $code = ($tx->req->error // {})->{advice}) { $res->code($code) }
return if $tx->res->code;
$c->render_not_found unless $self->routes->dispatch($c) || $tx->res->code;
}

Expand Down
5 changes: 3 additions & 2 deletions t/mojolicious/lite_app.t
Expand Up @@ -788,10 +788,10 @@ $t->app->log->unsubscribe(message => $cb);
# With body and max message size
{
local $ENV{MOJO_MAX_MESSAGE_SIZE} = 1024;
$t->get_ok('/', '1234' x 1024)->status_is(413)
$t->get_ok('/', '1234' x 1024)->status_is(200)
->header_is(Connection => 'close')
->content_is(
"/root.html\n/root.html\n/root.html\n/root.html\n/root.html\n");
"413\n/root.html\n/root.html\n/root.html\n/root.html\n/root.html\n");
}

# Relaxed placeholder
Expand Down Expand Up @@ -1103,6 +1103,7 @@ Test ok!
@@ root.html.epl
% my $c = shift;
<% if (my $err = $c->req->error) { =%><%= "$err->{advice}\n" %><% } =%>
%== $c->url_for('root_path')
%== $c->url_for('root_path')
%== $c->url_for('root_path')
Expand Down

0 comments on commit 9f3bb31

Please sign in to comment.