X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=lib%2FPublicInbox%2FWwwStream.pm;fp=lib%2FPublicInbox%2FWwwStream.pm;h=115e04407f1c022624ee22040e6ea6c06a0b1fc7;hp=f2777fdc64f8a33fdaa945db9f7eded819514dc2;hb=0eec12d630c1bac6f5a7850f37a7d67ecdbadf7e;hpb=133c9c61c0fe7e0e2d8d00e9935b3433b806ddc7 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 {