+ # XXX unstable API!, only GitHTTPBackend needs
+ # this to limit git-http-backend(1) parallelism.
+ # We also check for the truthiness of this to
+ # detect when to use async paths for slow blobs
+ 'pi-httpd.async' => \&pi_httpd_async,
+ 'pi-httpd.app' => $self->{app},
+ }
+}
+
+sub refresh_groups {
+ my ($self) = @_;
+ my $app;
+ $self->{psgi} //= $main::ARGV[0] if @main::ARGV;
+ if ($self->{psgi}) {
+ eval { $app = Plack::Util::load_psgi($self->{psgi}) };
+ die $@, <<EOM if $@;
+$0 runs in /, command-line paths must be absolute
+EOM
+ } else {
+ require PublicInbox::WWW;
+ my $www = PublicInbox::WWW->new;
+ $www->preload;
+ $app = builder {
+ eval { enable 'ReverseProxy' };
+ $@ and warn <<EOM;
+Plack::Middleware::ReverseProxy missing,
+URL generation for redirects may be wrong if behind a reverse proxy
+EOM
+ enable 'Head';
+ sub { $www->call(@_) };
+ };
+ }
+ $_->{'pi-httpd.app'} = $app for values %{$self->{envs}};
+ $self->{app} = $app;
+}
+
+sub post_accept_cb { # for Listener->{post_accept}
+ my ($self) = @_;
+ sub {
+ my ($client, $addr, $srv) = @_; # $_[4] - tls_wrap (unused)
+ PublicInbox::HTTP->new($client, $addr,
+ $self->{envs}->{fileno($srv)} //=
+ env_for($self, $srv, $client));
+ }