+sub html_oneshot ($$;$) {
+ my ($ctx, $code, $sref) = @_;
+ $ctx->{base_url} = base_url($ctx);
+ bless $ctx, __PACKAGE__;
+ my @x;
+ my $h = [ 'Content-Type' => 'text/html; charset=UTF-8',
+ 'Content-Length' => undef ];
+ if (my $gzf = gzf_maybe($h, $ctx->{env})) {
+ $gzf->zmore(html_top($ctx));
+ $gzf->zmore($$sref) if $sref;
+ $x[0] = $gzf->zflush(_html_end($ctx));
+ $h->[3] = length($x[0]);
+ } else {
+ @x = (html_top($ctx), $sref ? $$sref : (), _html_end($ctx));
+ $h->[3] += bytes::length($_) for @x;
+ }
+ [ $code, $h, \@x ]