/
request-secure.t
73 lines (64 loc) · 1.2 KB
/
request-secure.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use strict;
use warnings;
use Test::Base;
use HTTP::Engine::Request;
use t::Utils;
plan tests => 3*blocks;
filters { env => ['yaml'] };
run {
my $block = shift;
my $req = req(env => $block->env);
my $secure = $req->secure;
is qq{"$secure"} , $block->is_secure;
is $req->uri , $block->uri;
is $req->uri->port, $block->port;
}
__END__
===
--- env
HTTP_HOST: example.com
psgi.url_scheme: https
SERVER_PORT: 443
--- is_secure: "1"
--- uri: https://example.com/
--- port: 443
===
--- env
HTTP_HOST: example.com
psgi.url_scheme: http
SERVER_PORT: 80
--- is_secure: "0"
--- uri: http://example.com/
--- port: 80
===
--- env
HTTP_HOST: example.com
psgi.url_scheme: http
SERVER_PORT: 80
--- is_secure: "0"
--- uri: http://example.com/
--- port: 80
===
--- env
HTTP_HOST: example.com
SERVER_PORT: 8443
psgi.url_scheme: https
--- is_secure: "1"
--- uri: https://example.com:8443/
--- port: 8443
===
--- env
HTTP_HOST: example.com
SERVER_PORT: 443
psgi.url_scheme: https
--- is_secure: "1"
--- uri: https://example.com/
--- port: 443
===
--- env
HTTP_HOST: example.com
SERVER_PORT: 80
psgi.url_scheme: http
--- is_secure: "0"
--- uri: http://example.com/
--- port: 80