-
Notifications
You must be signed in to change notification settings - Fork 0
/
50servername.t
55 lines (48 loc) · 1.52 KB
/
50servername.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
use strict;
use warnings;
use Test::More;
use t::Util;
plan skip_all => 'curl not found'
unless prog_exists('curl');
subtest "default server header" => sub {
my $server = spawn_h2o(<< "EOT");
hosts:
default:
paths:
/:
file.dir: @{[ DOC_ROOT ]}
EOT
my $resp = `curl --silent --dump-header /dev/stderr http://127.0.0.1:$server->{port}/index.txt 2>&1 > /dev/null`;
like $resp, qr{^HTTP/1\.1 200 }s, "200 response";
like $resp, qr{^server: h2o/.*\r$}im, "h2o default Server: header found";
is +(() = $resp =~ m{^server}img), 1, "header added only once";
};
subtest "alternate server header" => sub {
my $server = spawn_h2o(<< "EOT");
hosts:
default:
paths:
/:
file.dir: @{[ DOC_ROOT ]}
server-name: h2oalternate
EOT
my $resp = `curl --silent --dump-header /dev/stderr http://127.0.0.1:$server->{port}/index.txt 2>&1 > /dev/null`;
like $resp, qr{^HTTP/1\.1 200 }s, "200 response";
like $resp, qr{^server: h2oalternate\r$}im, "alternate h2o Server: header found";
is +(() = $resp =~ m{^server}img), 1, "header added only once";
};
subtest "no server header" => sub {
my $server = spawn_h2o(<< "EOT");
hosts:
default:
paths:
/:
file.dir: @{[ DOC_ROOT ]}
server-name: h2oalternate
send-server-name: OFF
EOT
my $resp = `curl --silent --dump-header /dev/stderr http://127.0.0.1:$server->{port}/index.txt 2>&1 > /dev/null`;
like $resp, qr{^HTTP/1\.1 200 }s, "200 response";
unlike $resp, qr{^server}, "server unset";
};
done_testing();