diff options
author | Eric Wong <e@80x24.org> | 2022-09-10 08:16:54 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-09-10 19:50:26 +0000 |
commit | 0eec12d630c1bac6f5a7850f37a7d67ecdbadf7e (patch) | |
tree | 9171a8dc1b5ed70916c012a51dc2e40696566086 /lib/PublicInbox/WwwStream.pm | |
parent | 133c9c61c0fe7e0e2d8d00e9935b3433b806ddc7 (diff) | |
download | public-inbox-0eec12d630c1bac6f5a7850f37a7d67ecdbadf7e.tar.gz |
We can rely on deflate to compress large thread skeletons on single message pages. Subsequent commits will compress bodies, as well.
Diffstat (limited to 'lib/PublicInbox/WwwStream.pm')
-rw-r--r-- | lib/PublicInbox/WwwStream.pm | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm index f2777fdc..115e0440 100644 --- a/lib/PublicInbox/WwwStream.pm +++ b/lib/PublicInbox/WwwStream.pm @@ -27,6 +27,9 @@ sub init { my ($ctx, $cb) = @_; $ctx->{cb} = $cb; $ctx->{base_url} = base_url($ctx); + $ctx->{-res_hdr} = [ 'Content-Type' => 'text/html; charset=UTF-8' ]; + $ctx->{gz} = PublicInbox::GzipFilter::gz_or_noop($ctx->{-res_hdr}, + $ctx->{env}); bless $ctx, __PACKAGE__; } @@ -164,6 +167,14 @@ sub getline { $ctx->zflush(_html_end($ctx)); } +sub html_done ($$) { + my ($ctx, $code) = @_; + my $bdy = $ctx->zflush(_html_end($ctx)); + my $res_hdr = delete $ctx->{-res_hdr}; + push @$res_hdr, 'Content-Length', length($bdy); + [ $code, $res_hdr, [ $bdy ] ] +} + sub html_oneshot ($$;@) { my ($ctx, $code) = @_[0, 1]; my $res_hdr = [ 'Content-Type' => 'text/html; charset=UTF-8', @@ -195,9 +206,8 @@ sub async_next ($) { sub aresponse { my ($ctx, $code, $cb) = @_; - my $res_hdr = [ 'Content-Type' => 'text/html; charset=UTF-8' ]; init($ctx, $cb); - $ctx->psgi_response($code, $res_hdr); + $ctx->psgi_response($code, delete $ctx->{-res_hdr}); } sub html_init { |