We can save some cycles by delaying the potentially expensive
app invocation until after the PATH_INFO + user-agent check.
my ($self, $env) = @_;
my $ua = $env->{HTTP_USER_AGENT} // '';
return [ 403, [], [] ] if $ua =~ /$bad_ua/o;
- my $res = $self->app->($env);
my $uri;
if ($env->{PATH_INFO} !~ /\.css\z/ &&
$ua =~ m!\A(?:Mozilla|Opera)/! &&
[ 200, [ 'Refresh' => 1,
'Content-Length' => length($body) ], [ $body ] ]
} else {
- $res;
+ $self->app->($env);
}
}