View | Details | Raw Unified | Return to bug 20081
Collapse All | Expand All

(-)a/Koha/UploadedFile.pm (-4 / +11 lines)
Lines 134-143 Will be extended by report 14282 Link Here
134
134
135
sub httpheaders {
135
sub httpheaders {
136
    my ( $self ) = @_;
136
    my ( $self ) = @_;
137
    return (
137
    if( $self->filename =~ /\.pdf$/ ) {
138
        '-type'       => 'application/octet-stream',
138
        return (
139
        '-attachment' => $self->filename,
139
            '-type'       => 'application/pdf',
140
    );
140
            'Content-Disposition' => 'inline; filename='.$self->filename,
141
        );
142
    } else {
143
        return (
144
            '-type'       => 'application/octet-stream',
145
            '-attachment' => $self->filename,
146
        );
147
    }
141
}
148
}
142
149
143
=head2 CLASS METHODS
150
=head2 CLASS METHODS
(-)a/t/db_dependent/Upload.t (-2 / +12 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use File::Temp qw/ tempdir /;
4
use File::Temp qw/ tempdir /;
5
use Test::More tests => 12;
5
use Test::More tests => 13;
6
use Test::Warn;
6
use Test::Warn;
7
7
8
use Test::MockModule;
8
use Test::MockModule;
Lines 316-321 subtest 'Testing delete_temporary' => sub { Link Here
316
        'Still 3 permanent uploads' );
316
        'Still 3 permanent uploads' );
317
};
317
};
318
318
319
subtest 'Testing download headers' => sub {
320
    plan tests => 2;
321
    my $test_pdf = Koha::UploadedFile->new({ filename => 'pdf.pdf', uploadcategorycode => 'B', filesize => 1000 });
322
    my $test_not = Koha::UploadedFile->new({ filename => 'pdf.not', uploadcategorycode => 'B', filesize => 1000 });
323
    my @pdf_expect = ( '-type'=>'application/pdf','Content-Disposition'=>'inline; filename=pdf.pdf' );
324
    my @not_expect = ( '-type'=>'application/octet-stream','-attachment'=>'pdf.not' );
325
    my @pdf_head = $test_pdf->httpheaders;
326
    my @not_head = $test_not->httpheaders;
327
    is_deeply(\@pdf_head, \@pdf_expect,"Get inline pdf headers for pdf");
328
    is_deeply(\@not_head, \@not_expect,"Get download headers for non pdf");
329
};
319
# The end
330
# The end
320
$schema->storage->txn_rollback;
331
$schema->storage->txn_rollback;
321
332
322
- 

Return to bug 20081