Skip to content

Commit a4b0090

Browse files
committed
Merge pull request #305 from nadoshmado/gh-272
Fix GH#272
2 parents 5d5281a + 3f26a0f commit a4b0090

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/MetaCPAN/Server/Controller/Source.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use warnings;
55

66
use Moose;
77
use Plack::App::Directory;
8+
use Plack::MIME;
89

910
BEGIN { extends 'MetaCPAN::Server::Controller' }
1011

@@ -32,7 +33,7 @@ sub get : Chained('index') : PathPart('') : Args {
3233
}
3334
else {
3435
$c->stash->{path} = $file;
35-
$c->res->content_type('text/plain');
36+
$c->res->content_type(Plack::MIME->mime_type($file) || 'text/plain');
3637
$c->res->body( $file->openr );
3738
}
3839
}

t/server/controller/source.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_psgi app, sub {
2222
if ( $k eq '/source/Moose' ) {
2323
like( $res->content, qr/package Moose/, 'Moose source' );
2424
is( $res->header('content-type'),
25-
'text/plain; charset=UTF-8',
25+
'text/x-script.perl-module; charset=UTF-8',
2626
'Content-type'
2727
);
2828
}

0 commit comments

Comments
 (0)