+sub html_oneshot ($$;$) {
+ my ($ctx, $code, $sref) = @_;
+ my $self = bless {
+ ctx => $ctx,
+ base_url => base_url($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($self));
+ $gzf->zmore($$sref) if $sref;
+ $x[0] = $gzf->zflush(_html_end($self));
+ $h->[3] = length($x[0]);
+ } else {
+ @x = (_html_top($self), $sref ? $$sref : (), _html_end($self));
+ $h->[3] += bytes::length($_) for @x;
+ }
+ [ $code, $h, \@x ]