/
17-test-content-type-handling.t
54 lines (39 loc) · 1.43 KB
/
17-test-content-type-handling.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use v6.c;
use Test;
use Bailador;
use Bailador::Test;
plan 6;
get '/default_autorender' => sub {
"Hi";
}
get '/defined_autorender' => sub {
content_type('application/json');
'{}';
}
get '/defined_render' => sub {
render(content => '{}', type => 'application/json');
}
get '/default_render' => sub {
render(content => "Hi");
}
static-dir rx/ (.*) / => 'data/';
# Call baile just once
my $p6w-app = baile('p6w');
my $response = get-psgi-response($p6w-app, 'GET', '/file.txt');
is $response[1], ["Content-Type" => "text/plain;charset=UTF-8"], 'content type discovery';
$response = get-psgi-response($p6w-app, 'GET', '/unknown.extention');
# test 2
if $*DISTRO.is-win {
skip "Skipping failing Windows test...";
}
else {
is $response[1], ["Content-Type" => "application/octet-stream"], 'content type discovery fallback';
}
$response = get-psgi-response($p6w-app, 'GET', '/default_autorender');
is $response[1], [Content-Type => 'text/html'], 'content type autorender default';
$response = get-psgi-response($p6w-app, 'GET', '/defined_autorender');
is $response[1], [Content-Type => 'application/json'], 'content type autorender defined';
$response = get-psgi-response($p6w-app, 'GET', '/default_render');
is $response[1], [Content-Type => 'text/html'], 'content type default';
$response = get-psgi-response($p6w-app, 'GET', '/defined_render');
is $response[1], [Content-Type => 'application/json'], 'content type defined';