-
Notifications
You must be signed in to change notification settings - Fork 0
/
50mimemap.t
57 lines (51 loc) · 1.48 KB
/
50mimemap.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
55
56
57
use strict;
use warnings;
use Test::More;
use t::Util;
my $server = spawn_h2o(<< 'EOT');
hosts:
default:
paths:
/:
file.dir: t/50mimemap/doc_root
/addtypes:
file.dir: t/50mimemap/doc_root
file.mime.addtypes:
application/xhtml+xml: .xhtml
/removetypes:
file.dir: t/50mimemap/doc_root
file.mime.removetypes:
- .xhtml
/settypes:
file.dir: t/50mimemap/doc_root
file.mime.settypes:
text/xml: .xhtml
file.mime.addtypes:
application/xml: .xhtml
default-type-test:
paths:
/:
file.dir: t/50mimemap/doc_root
file.mime.setdefaulttype: application/xhtml+xml
file.index:
- index.xhtml
EOT
plan skip_all => 'curl not found'
unless prog_exists('curl');
my $CURL_CMD = q{curl --silent --show-error --output /dev/null --write-out '%{content_type}'};
my $port = $server->{port};
my %expected = (
'/' => 'application/xml',
'/addtypes/' => 'application/xhtml+xml',
'/removetypes/' => 'application/octet-stream',
'/settypes/' => 'text/xml',
);
for my $path (sort keys %expected) {
my $ct = `$CURL_CMD http://127.0.0.1:$port$path`;
is $ct, $expected{$path}, "$path";
$ct = `$CURL_CMD http://127.0.0.1:$port${path}index.xhtml`;
is $ct, $expected{$path}, "${path}index.xhtml";
}
my $ct = `$CURL_CMD --header 'host: default-type-test' http://127.0.0.1:$port/`;
is $ct, 'application/xhtml+xml', 'setdefaulttype';
done_testing;