-use warnings;
-use PublicInbox::Hval qw(ascii_html);
-use URI;
-use constant PI_URL => 'https://public-inbox.org/README.html';
-
-sub new {
- my ($class, $ctx, $cb) = @_;
- bless { nr => 0, cb => $cb, ctx => $ctx }, $class;
+use parent qw(Exporter);
+our @EXPORT_OK = qw(html_oneshot);
+use bytes (); # length
+use PublicInbox::Hval qw(ascii_html prurl);
+use PublicInbox::GzipFilter qw(gzf_maybe);
+our $TOR_URL = 'https://www.torproject.org/';
+our $CODE_URL = 'https://public-inbox.org/public-inbox.git';
+
+# noop for HTTP.pm (and any other PSGI servers)
+sub close {}
+
+sub base_url ($) {
+ my $ctx = shift;
+ my $base_url = $ctx->{-inbox}->base_url($ctx->{env});
+ chop $base_url; # no trailing slash for clone
+ $base_url;
+}
+
+sub init {
+ my ($ctx, $cb) = @_;
+ $ctx->{cb} = $cb;
+ $ctx->{base_url} = base_url($ctx);
+ bless $ctx, __PACKAGE__;
+}
+
+sub response {
+ my ($ctx, $code, $cb) = @_;
+ my $h = [ 'Content-Type', 'text/html; charset=UTF-8' ];
+ init($ctx, $cb);
+ $ctx->{gzf} = gzf_maybe($h, $ctx->{env});
+ [ $code, $h, $ctx ]