| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::More tests => 2; |
| 4 |
use Plack::Test; |
| 5 |
use HTTP::Request::Common; |
| 6 |
|
| 7 |
{ |
| 8 |
package App::MIME; |
| 9 |
use Dancer2; |
| 10 |
|
| 11 |
# set some MIME aliases... |
| 12 |
mime->add_type( foo => 'text/foo' ); |
| 13 |
mime->add_alias( f => 'foo' ); |
| 14 |
|
| 15 |
# Set default mime type |
| 16 |
set 'default_mime_type' => 'text/bar'; |
| 17 |
|
| 18 |
# test static corpus |
| 19 |
set static_handler => 1; |
| 20 |
set public_dir => 't/corpus/static'; |
| 21 |
|
| 22 |
# added type |
| 23 |
get '/foo' => sub { |
| 24 |
send_file 'empty.foo'; |
| 25 |
}; |
| 26 |
|
| 27 |
} |
| 28 |
|
| 29 |
my $app = Plack::Test->create( App::MIME->to_app ); |
| 30 |
|
| 31 |
|
| 32 |
subtest 'send_file content type' => sub { |
| 33 |
my $res = $app->request( GET '/foo' ); |
| 34 |
ok( $res->is_success, 'Successful request' ); |
| 35 |
is( $res->content_type, 'text/foo', '.. and correct mime type'); |
| 36 |
|
| 37 |
}; |
| 38 |
|
| 39 |
# Ref: #1546 |
| 40 |
subtest 'static handler content type' => sub { |
| 41 |
my $res = $app->request( GET '/empty.foo' ); |
| 42 |
ok( $res->is_success, 'Successful request via static handler' ); |
| 43 |
is( $res->content_type, 'text/foo', '.. and correct mime type'); |
| 44 |
}; |