Some folks may want to view the mbox inline as a string of raw text,
when guessing URLs. Let them do this...
use PublicInbox::MID qw/mid_compressed mid2path/;
sub thread_mbox {
use PublicInbox::MID qw/mid_compressed mid2path/;
sub thread_mbox {
+ my ($ctx, $srch, $sfx) = @_;
sub {
my ($response) = @_; # Plack callback
sub {
my ($response) = @_; # Plack callback
- emit_mbox($response, $ctx, $srch);
+ emit_mbox($response, $ctx, $srch, $sfx);
- my ($response, $ctx, $srch) = @_;
- eval { require IO::Compress::Gzip };
- return need_gzip($response) if $@;
+ my ($response, $ctx, $srch, $sfx) = @_;
+ my $type = 'mbox';
+ if ($sfx) {
+ eval { require IO::Compress::Gzip };
+ return need_gzip($response) if $@;
+ $type = 'gzip';
+ }
# http://www.iana.org/assignments/media-types/application/gzip
# http://www.iana.org/assignments/media-types/application/mbox
# http://www.iana.org/assignments/media-types/application/gzip
# http://www.iana.org/assignments/media-types/application/mbox
- my $fh = $response->([200, ['Content-Type' => 'application/gzip']]);
- $fh = PublicInbox::MboxGz->new($fh);
+ my $fh = $response->([200, ['Content-Type' => "application/$type"]]);
+ $fh = PublicInbox::MboxGz->new($fh) if $sfx;
require PublicInbox::GitCatFile;
require Email::Simple;
require PublicInbox::GitCatFile;
require Email::Simple;
} elsif ($path_info =~ m!$LISTNAME_RE/t/(\S+)\.html\z!o) {
invalid_list_mid(\%ctx, $1, $2) || get_thread(\%ctx, $cgi);
} elsif ($path_info =~ m!$LISTNAME_RE/t/(\S+)\.html\z!o) {
invalid_list_mid(\%ctx, $1, $2) || get_thread(\%ctx, $cgi);
- } elsif ($path_info =~ m!$LISTNAME_RE/t/(\S+)\.mbox\.gz!o) {
+ } elsif ($path_info =~ m!$LISTNAME_RE/t/(\S+)\.mbox(\.gz)?\z!o) {
- invalid_list_mid(\%ctx, $1, $2) || get_thread_mbox(\%ctx, $cgi);
+ invalid_list_mid(\%ctx, $1, $2) ||
+ get_thread_mbox(\%ctx, $cgi, $sfx);
} elsif ($path_info =~ m!$LISTNAME_RE/f/\S+\.txt\z!o) {
invalid_list_mid(\%ctx, $1, $2) ||
} elsif ($path_info =~ m!$LISTNAME_RE/f/\S+\.txt\z!o) {
invalid_list_mid(\%ctx, $1, $2) ||
-# /$LISTNAME/t/$MESSAGE_ID.mbox.gz -> search results as gzipped mbox
+# /$LISTNAME/t/$MESSAGE_ID.mbox -> thread as mbox
+# /$LISTNAME/t/$MESSAGE_ID.mbox.gz -> thread as gzipped mbox
# note: I'm not a big fan of other compression formats since they're
# significantly more expensive on CPU than gzip and less-widely available,
# especially on older systems. Stick to zlib since that's what git uses.
sub get_thread_mbox {
# note: I'm not a big fan of other compression formats since they're
# significantly more expensive on CPU than gzip and less-widely available,
# especially on older systems. Stick to zlib since that's what git uses.
sub get_thread_mbox {
+ my ($ctx, $cgi, $sfx) = @_;
my $srch = searcher($ctx) or return need_search($ctx);
require PublicInbox::Mbox;
my $srch = searcher($ctx) or return need_search($ctx);
require PublicInbox::Mbox;
- PublicInbox::Mbox::thread_mbox($ctx, $srch);
+ PublicInbox::Mbox::thread_mbox($ctx, $srch, $sfx);