Skip to content

Commit

Permalink
fixed bug where Mojolicious::Static would not use the correct default…
Browse files Browse the repository at this point in the history
… MIME type
  • Loading branch information
kraih committed Apr 9, 2014
1 parent ea714cc commit 2734ce6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,5 +1,7 @@

4.93 2014-04-09
- Fixed bug where Mojolicious::Static would not use the correct default MIME
type.

4.92 2014-04-08
- Removed deprecated use of hash references for optgroup generation with
Expand Down
5 changes: 3 additions & 2 deletions lib/Mojolicious/Static.pm
Expand Up @@ -52,8 +52,9 @@ sub file {
sub serve {
my ($self, $c, $rel) = @_;
return undef unless my $asset = $self->file($rel);
my $type = $rel =~ /\.(\w+)$/ ? $c->app->types->type($1) : undef;
$c->res->headers->content_type($type || 'text/plain');
my $types = $c->app->types;
$c->res->headers->content_type(
$types->type($rel =~ /\.(\w+)$/ ? $1 : 'txt'));
return !!$self->serve_asset($c, $asset);
}

Expand Down
3 changes: 2 additions & 1 deletion t/mojolicious/app.t
Expand Up @@ -351,7 +351,8 @@ $t->get_ok('/' => {'X-Test' => 'Hi there!'})->status_is(404)

# Static file /another/file (no extension)
$t->get_ok('/another/file')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')->content_type_is('text/plain')
->header_is(Server => 'Mojolicious (Perl)')
->content_type_is('text/plain;charset=UTF-8')
->content_like(qr/Hello Mojolicious!/);

# Static directory /another
Expand Down

0 comments on commit 2734ce6

Please sign in to comment.