about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-09-10 08:16:58 +0000
committerEric Wong <e@80x24.org>2022-09-10 19:50:29 +0000
commit0ff8c4f7e0815a0aa2e9935dd07ae446ce83c906 (patch)
treef78d95863027d2eab6b6cf374dd24f80d14002a7 /lib
parent10839bf81e72f7699ba818db35237028731cf1fd (diff)
downloadpublic-inbox-0ff8c4f7e0815a0aa2e9935dd07ae446ce83c906.tar.gz
viewvcs: use shorter and simpler ctx->html_done
We only return 200s for any response large enough to warrant
->html_done, so we can just assume it.  ViewVCS can also take
advantage of it with some tweaking to avoid an extra method
dispatch.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/View.pm2
-rw-r--r--lib/PublicInbox/ViewVCS.pm5
-rw-r--r--lib/PublicInbox/WwwStream.pm8
3 files changed, 6 insertions, 9 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 1cbc62be..c6fd05cc 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -61,7 +61,7 @@ sub no_over_html ($) {
                 ${$ctx->{obuf}} .= '</pre><hr>';
         }
         html_footer($ctx, $eml);
-        $ctx->html_done(200);
+        $ctx->html_done;
 }
 
 # public functions: (unstable)
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index ed4a6454..d3ac1a7d 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -253,10 +253,7 @@ possible to have multiple root commits when merging independent histories.
 
 Every commit references one top-level <dfn id=tree>tree</dfn> object.</pre>
 EOM
-        $x = $ctx->zflush($x, $ctx->_html_end);
-        my $res_hdr = delete $ctx->{-res_hdr};
-        push @$res_hdr, 'Content-Length', length($x);
-        delete($ctx->{env}->{'qspawn.wcb'})->([200, $res_hdr, [$x]]);
+        delete($ctx->{env}->{'qspawn.wcb'})->($ctx->html_done($x));
 }
 
 sub stream_patch_parse_hdr { # {parse_hdr} for Qspawn
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index 1fc213d4..c23668a4 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -167,12 +167,12 @@ sub getline {
         $ctx->zflush(_html_end($ctx));
 }
 
-sub html_done ($$) {
-        my ($ctx, $code) = @_;
-        my $bdy = $ctx->zflush(_html_end($ctx));
+sub html_done ($;@) {
+        my $ctx = $_[0];
+        my $bdy = $ctx->zflush(@_[1..$#_], _html_end($ctx));
         my $res_hdr = delete $ctx->{-res_hdr};
         push @$res_hdr, 'Content-Length', length($bdy);
-        [ $code, $res_hdr, [ $bdy ] ]
+        [ 200, $res_hdr, [ $bdy ] ]
 }
 
 sub html_oneshot ($$;@) {