From: Eric Wong Date: Sun, 13 Jul 2025 00:08:34 +0000 (+0000) Subject: http: expose reused connection counter in PSGI env X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a0e93016f6649340844c9d3a11cf2435ab6ca19;p=thirdparty%2Fpublic-inbox.git http: expose reused connection counter in PSGI env `$env->{pi-httpd.request_nr}' is now accessible via the PSGI env for middlewares to use to identify reused connections. This can be useful for middlewares to implement rules for identifying and rejecting/allowing certain clients (e.g. aggressive bots). --- diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index 83f2c6a24..3cb3b35fb 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -144,6 +144,7 @@ sub app_dispatch { my ($self, $input, $rbuf) = @_; $self->rbuf_idle($rbuf); my $env = $self->{env}; + $env->{'pi-httpd.request_nr'} = $self->{request_nr}++; $self->{env} = undef; # for exists() check in ->busy $env->{REMOTE_ADDR} = $self->{remote_addr} // '127.0.0.1'; $env->{REMOTE_PORT} = $self->{remote_port};