-sub emit1 {
- my $simple = Email::Simple->new(pop);
- sub {
- my ($response) = @_;
- # single message should be easily renderable in browsers
- my $fh = $response->([200, ['Content-Type'=>'text/plain']]);
- emit_msg($fh, $simple);
+sub close {} # noop
+
+sub emit_raw {
+ my ($ctx) = @_;
+ my $mid = $ctx->{mid};
+ my $ibx = $ctx->{-inbox};
+ my ($mref, $more, $id, $prev, $next);
+ if (my $over = $ibx->over) {
+ my $smsg = $over->next_by_mid($mid, \$id, \$prev) or return;
+ $mref = $ibx->msg_by_smsg($smsg) or return;
+ $next = $over->next_by_mid($mid, \$id, \$prev);
+ } else {
+ $mref = $ibx->msg_by_mid($mid) or return;
+ }
+ my $hdr = Email::Simple->new($mref)->header_obj;
+ $more = [ $ctx, $id, $prev, $next, $mref, $hdr ]; # for ->getline
+ my $fn = subject_fn($hdr);
+ my @hdr = ('Content-Type');
+ if ($ibx->{obfuscate}) {
+ # obfuscation is stupid, but maybe scrapers are, too...
+ push @hdr, 'application/mbox';
+ $fn .= '.mbox';
+ } else {
+ push @hdr, 'text/plain';
+ $fn .= '.txt';