Skip to content

Commit

Permalink
Add a X-Content-Type header start for #272
Browse files Browse the repository at this point in the history
  • Loading branch information
ranguard committed Apr 9, 2014
1 parent 45c0241 commit d1d874d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/MetaCPAN/Server/Controller/Source.pm
Expand Up @@ -5,6 +5,7 @@ use warnings;

use Moose;
use Plack::App::Directory;
use Plack::MIME;

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

Expand Down Expand Up @@ -32,6 +33,7 @@ sub get : Chained('index') : PathPart('') : Args {
}
else {
$c->stash->{path} = $file;
$c->res->header( 'X-Content-Type' => Plack::MIME->mime_type($file) || 'text/plain' );
$c->res->content_type('text/plain');
$c->res->body( $file->openr );
}
Expand Down
5 changes: 5 additions & 0 deletions t/server/controller/source.t
Expand Up @@ -25,6 +25,11 @@ test_psgi app, sub {
'text/plain; charset=UTF-8',
'Content-type'
);
is( $res->header('X-Content-Type'),
'x-script.perl-module; charset=UTF-8',
'X-Content-Type'
);

}
elsif ( $k =~ /MANIFEST/ ) {

Expand Down

0 comments on commit d1d874d

Please sign in to comment.