# Copyright (C) 2015-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-# Streaming (via getline) interface for formatting messages as an mboxrd.
-# Used by the PSGI web interface.
-#
-# public-inbox-httpd favors "getline" response bodies to take a
-# "pull"-based approach to feeding slow clients (as opposed to a
-# more common "push" model)
+# Streaming interface for mboxrd HTTP responses
+# See PublicInbox::GzipFilter for details.
package PublicInbox::Mbox;
use strict;
use parent 'PublicInbox::GzipFilter';
}
}
-# called by PublicInbox::DS::write
+# called by PublicInbox::DS::write after http->next_step
sub async_next {
my ($http) = @_; # PublicInbox::HTTP
my $ctx = $http->{forward} or return; # client aborted
warn "E: $@" if $@;
}
-sub async_eml { # ->{async_eml} for async_blob_cb
+sub async_eml { # for async_blob_cb
my ($ctx, $eml) = @_;
my $smsg = delete $ctx->{smsg};
# next message
sub res_hdr ($$) {
my ($ctx, $subject) = @_;
- my $fn = $subject // 'no-subject';
+ my $fn = $subject // '';
$fn =~ s/^re:\s+//i;
- $fn = $fn eq '' ? 'no-subject' : to_filename($fn);
+ $fn = to_filename($fn) // 'no-subject';
my @hdr = ('Content-Type');
if ($ctx->{-inbox}->{obfuscate}) {
# obfuscation is stupid, but maybe scrapers are, too...
my $smsg = $ctx->{smsg} = $over->next_by_mid(@$mip) or return;
my $res_hdr = res_hdr($ctx, $smsg->{subject});
bless $ctx, __PACKAGE__;
- $ctx->psgi_response(200, $res_hdr, \&async_next, \&async_eml);
+ $ctx->psgi_response(200, $res_hdr);
}
sub msg_hdr ($$;$) {