From 7772b32046448b5407d9bbb2783b8aa0e6a34689 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 2 Sep 2025 20:30:12 +0000 Subject: [PATCH] reject_bots: delay app call We can save some cycles by delaying the potentially expensive app invocation until after the PATH_INFO + user-agent check. --- contrib/RejectBots.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/RejectBots.pm b/contrib/RejectBots.pm index 28561fa79..fdfd41a53 100644 --- a/contrib/RejectBots.pm +++ b/contrib/RejectBots.pm @@ -22,7 +22,6 @@ sub call { 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)/! && @@ -35,7 +34,7 @@ EOM [ 200, [ 'Refresh' => 1, 'Content-Length' => length($body) ], [ $body ] ] } else { - $res; + $self->app->($env); } } -- 2.47.3