diff options
author | Eric Wong <e@80x24.org> | 2015-08-22 11:41:23 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-08-22 11:42:37 +0000 |
commit | 6b51c6e762de67636c90b678b4bb28f970379b3c (patch) | |
tree | e27ec8e877b095c32fbaad69381e8dbdec4250ac /lib/PublicInbox/Mbox.pm | |
parent | 746323cbde3f5da5d66efe742b30894b0d806ffe (diff) | |
download | public-inbox-6b51c6e762de67636c90b678b4bb28f970379b3c.tar.gz |
Some folks may want to view the mbox inline as a string of raw text, when guessing URLs. Let them do this...
Diffstat (limited to 'lib/PublicInbox/Mbox.pm')
-rw-r--r-- | lib/PublicInbox/Mbox.pm | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm index 5f5612a4..d49e9b39 100644 --- a/lib/PublicInbox/Mbox.pm +++ b/lib/PublicInbox/Mbox.pm @@ -7,10 +7,10 @@ use warnings; use PublicInbox::MID qw/mid_compressed mid2path/; sub thread_mbox { - my ($ctx, $srch) = @_; + my ($ctx, $srch, $sfx) = @_; sub { my ($response) = @_; # Plack callback - emit_mbox($response, $ctx, $srch); + emit_mbox($response, $ctx, $srch, $sfx); } } @@ -38,14 +38,18 @@ sub emit_msg { } sub emit_mbox { - 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 - 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; |