about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-01-30 09:19:06 +0000
committerEric Wong <e@yhbt.net>2020-01-31 23:00:07 +0000
commit31cb75037a757c9388f74283a8b1ecb7c5b65f24 (patch)
tree6989f99a3cb00272ff877218ebad85fabe0da903 /lib
parent3dff4a5399f10cbcb3d902da094680705c50193a (diff)
downloadpublic-inbox-31cb75037a757c9388f74283a8b1ecb7c5b65f24.tar.gz
Lets always have Content-Disposition for files intended
to be downloaded for consumption by non-browsers, such
as pigz, zcat, "git am".

This is also to be consistent with the non-gzipped mbox
$MESSAGE_ID/raw endpoint.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/MboxGz.pm10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/PublicInbox/MboxGz.pm b/lib/PublicInbox/MboxGz.pm
index 08e3c846..30074e4d 100644
--- a/lib/PublicInbox/MboxGz.pm
+++ b/lib/PublicInbox/MboxGz.pm
@@ -21,12 +21,10 @@ sub response {
         my ($class, $ctx, $cb, $fn) = @_;
         my $body = $class->new($ctx, $cb);
         # http://www.iana.org/assignments/media-types/application/gzip
-        my @h = qw(Content-Type application/gzip);
-        if (defined $fn && $fn ne '') {
-                $fn = to_filename($fn);
-                push @h, 'Content-Disposition', "inline; filename=$fn.mbox.gz";
-        }
-        [ 200, \@h, $body ];
+        $fn = defined($fn) && $fn ne '' ? to_filename($fn) : 'no-subject';
+        my $h = [ qw(Content-Type application/gzip),
+                'Content-Disposition', "inline; filename=$fn.mbox.gz" ];
+        [ 200, $h, $body ];
 }
 
 sub gzip_fail ($$) {