: $ctx->gone('over');
$ctx->{mhref} = ($ctx->{nr} || $ctx->{smsg}) ?
"../${\mid_href($smsg->{mid})}/" : '';
- my $obuf = _msg_page_prepare_obuf($eml, $ctx);
- if (length($$obuf)) {
+ if (_msg_page_prepare_obuf($eml, $ctx)) {
multipart_text_as_html($eml, $ctx);
- $$obuf .= '</pre><hr>';
+ ${$ctx->{obuf}} .= '</pre><hr>';
}
- delete $ctx->{obuf};
- $$obuf .= html_footer($ctx, $ctx->{first_hdr}) if !$ctx->{smsg};
- $$obuf;
+ html_footer($ctx, $ctx->{first_hdr}) if !$ctx->{smsg};
+ delete($ctx->{obuf}) // \'';
} else { # called by WwwStream::async_next or getline
$ctx->{smsg}; # may be undef
}
my $eml = PublicInbox::Eml->new($bref);
$ctx->{mhref} = '';
PublicInbox::WwwStream::init($ctx);
- my $obuf = _msg_page_prepare_obuf($eml, $ctx);
- if (length($$obuf)) {
+ if (_msg_page_prepare_obuf($eml, $ctx)) { # sets {-title_html}
multipart_text_as_html($eml, $ctx);
- $$obuf .= '</pre><hr>';
+ ${$ctx->{obuf}} .= '</pre><hr>';
}
- delete $ctx->{obuf};
- eval { $$obuf .= html_footer($ctx, $eml) };
- html_oneshot($ctx, 200, $$obuf);
+ html_footer($ctx, $eml);
+ $ctx->html_done(200);
}
# public functions: (unstable)
if ($nr) { # unlikely
if ($ctx->{chash} eq content_hash($eml)) {
warn "W: BUG? @$mids not deduplicated properly\n";
- return \$rv;
+ return;
}
$rv .=
"<pre>WARNING: multiple messages have this Message-ID\n</pre><pre>";
}
_parent_headers($ctx, $eml);
$rv .= "\n";
- \$rv;
+ 1;
}
sub SKEL_EXPAND () {
}
}
-# returns a string buffer
+# appends to obuf
sub html_footer {
my ($ctx, $hdr) = @_;
my $upfx = '../';
- my $skel;
- my $rv = '<pre>';
- my $related;
+ my ($related, $skel);
my $qry = delete $ctx->{-qry};
if ($qry && $ctx->{ibx}->isrch) {
my $q = ''; # search for either ancestor or descendent patches
} elsif ($u) { # unlikely
$parent = " <a\nhref=\"$u\"\nrel=prev>parent</a>";
}
- $rv .= "$next $prev$parent ";
+ ${$ctx->{obuf}} .= "<pre>$next $prev$parent ";
} else { # unindexed inboxes w/o over
+ ${$ctx->{obuf}} .= '<pre>';
$skel = qq( <a\nhref="$upfx">latest</a>);
}
- $rv .= qq(<a\nhref="#R">reply</a>);
- $rv .= $skel;
- $rv .= '</pre>';
- $rv .= $related // '';
- $rv .= msg_reply($ctx, $hdr);
+ ${$ctx->{obuf}} .= qq(<a\nhref="#R">reply</a>);
+ # $skel may be big for big threads, don't append it to obuf
+ $skel .= '</pre>' . ($related // '');
+ $ctx->zmore($skel .= msg_reply($ctx, $hdr)); # flushes obuf
}
sub linkify_ref_no_over {
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__;
}
$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',
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 {