]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Mbox.pm
www: rework async_* to use method table
[public-inbox.git] / lib / PublicInbox / Mbox.pm
index 8726b9f641b248e9f581f568a4eba67fb91e3657..fc83a893c60ab384f21061d3b2dff12edb6f365c 100644 (file)
@@ -29,7 +29,7 @@ sub getline {
        }
 }
 
-# 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
@@ -40,7 +40,7 @@ sub async_next {
        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
@@ -52,9 +52,9 @@ sub async_eml { # ->{async_eml} for async_blob_cb
 
 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...
@@ -87,7 +87,7 @@ sub emit_raw {
        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 ($$;$) {