about summary refs log tree commit homepage
path: root/lib/PublicInbox/WwwStream.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/WwwStream.pm')
-rw-r--r--lib/PublicInbox/WwwStream.pm23
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index eecc2701..7d257a19 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -29,14 +29,6 @@ sub init {
         bless $ctx, __PACKAGE__;
 }
 
-sub response {
-        my ($ctx, $code, $cb) = @_;
-        my $res_hdr = [ 'Content-Type' => 'text/html; charset=UTF-8' ];
-        init($ctx, $cb);
-        $ctx->{gz} = PublicInbox::GzipFilter::gz_or_noop($res_hdr, $ctx->{env});
-        [ $code, $res_hdr, $ctx ]
-}
-
 sub async_eml { # ->{async_eml} for async_blob_cb
         my ($ctx, $eml) = @_;
         $ctx->{http_out}->write($ctx->translate($ctx->{cb}->($ctx, $eml)));
@@ -174,17 +166,18 @@ sub getline {
 
 sub html_oneshot ($$;$) {
         my ($ctx, $code, $sref) = @_;
-        $ctx->{base_url} = base_url($ctx);
-        bless $ctx, __PACKAGE__;
-        my @bdy;
         my $res_hdr = [ 'Content-Type' => 'text/html; charset=UTF-8',
                 'Content-Length' => undef ];
+        bless $ctx, __PACKAGE__;
         $ctx->{gz} = PublicInbox::GzipFilter::gz_or_noop($res_hdr, $ctx->{env});
-        $ctx->zmore(html_top($ctx));
+        $ctx->{base_url} //= do {
+                $ctx->zmore(html_top($ctx));
+                base_url($ctx);
+        };
         $ctx->zmore($$sref) if $sref;
-        $bdy[0] = $ctx->zflush(_html_end($ctx));
-        $res_hdr->[3] = bytes::length($bdy[0]);
-        [ $code, $res_hdr, \@bdy ]
+        my $bdy = $ctx->zflush(_html_end($ctx));
+        $res_hdr->[3] = bytes::length($bdy);
+        [ $code, $res_hdr, [ $bdy ] ]
 }
 
 sub async_next ($) {