blob: 568b5a8f854953d327eed03e7d4aa15782934121 [file] [log] [blame]
Amaury Denoyelle8ba0c5d2021-07-07 10:49:29 +02001varnishtest "scheme based normalization (rfc3982 6.3.2)"
2#REQUIRE_VERSION=2.5
3
4feature ignore_unknown_macro
5
6syslog S1 -level info {
7 recv
8 expect ~ "^.* uri: GET http://hostname/ HTTP/2.0; host: {hostname}$"
9
10 recv
11 expect ~ "^.* uri: GET http://hostname:8080/ HTTP/2.0; host: {hostname:8080}$"
12
13 recv
14 expect ~ "^.* uri: GET https://hostname/ HTTP/2.0; host: {hostname}$"
15
16 recv
17 expect ~ "^.* uri: GET https://hostname:80/ HTTP/2.0; host: {hostname:80}$"
18} -start
19
20haproxy h1 -conf {
21 defaults
22 mode http
23 timeout connect 5s
24 timeout client 5s
25 timeout server 5s
26
27 frontend fe
28 bind "fd@${fe}" proto h2
29
30 http-request capture req.hdr(host) len 512
31 log-format "uri: %r; host: %hr"
32 log ${S1_addr}:${S1_port} len 2048 local0 debug err
33
34 http-request return status 200
35} -start
36
37# default port 80 with http scheme => should be normalized
38client c1 -connect ${h1_fe_sock} {
39 txpri
40 stream 0 {
41 txsettings
42 rxsettings
43 txsettings -ack
44 rxsettings
45 expect settings.ack == true
46 } -run
47
48 stream 1 {
49 txreq \
50 -req "GET" \
51 -scheme "http" \
52 -url "/" \
53 -hdr ":authority" "hostname:80"
54 rxhdrs
55 expect resp.status == 200
56 } -run
57} -run
58
59# port 8080 with http scheme => no normalization
60client c2 -connect ${h1_fe_sock} {
61 txpri
62 stream 0 {
63 txsettings
64 rxsettings
65 txsettings -ack
66 rxsettings
67 expect settings.ack == true
68 } -run
69
70 stream 1 {
71 txreq \
72 -req "GET" \
73 -scheme "http" \
74 -url "/" \
75 -hdr ":authority" "hostname:8080"
76 rxhdrs
77 expect resp.status == 200
78 } -run
79} -run
80
81# default port 443 with https scheme => should be normalized
82client c3 -connect ${h1_fe_sock} {
83 txpri
84 stream 0 {
85 txsettings
86 rxsettings
87 txsettings -ack
88 rxsettings
89 expect settings.ack == true
90 } -run
91
92 stream 1 {
93 txreq \
94 -req "GET" \
95 -scheme "https" \
96 -url "/" \
97 -hdr ":authority" "hostname:443"
98 rxhdrs
99 expect resp.status == 200
100 } -run
101} -run
102
103# port 80 with https scheme => no normalization
104client c4 -connect ${h1_fe_sock} {
105 txpri
106 stream 0 {
107 txsettings
108 rxsettings
109 txsettings -ack
110 rxsettings
111 expect settings.ack == true
112 } -run
113
114 stream 1 {
115 txreq \
116 -req "GET" \
117 -scheme "https" \
118 -url "/" \
119 -hdr ":authority" "hostname:80"
120 rxhdrs
121 expect resp.status == 200
122 } -run
123} -run
124
125syslog S1 -wait