blob: 7d122aa084fce7f84fbafd77728e09e05d5d72a6 [file] [log] [blame]
Amaury Denoyellebda34302020-12-11 17:53:11 +01001# This reg-test checks the full support of HTTP protocol upgrade, using a GET
2# method and a Connection: Upgrade header. The equivalent mechanism has been
3# defined in rfc8441 for HTTP/2 using CONNECT and a new pseudo-header
4# :protocol. Check that haproxy handles properly h1/h2 translation of protocol
5# upgrade requests and responses.
6
7varnishtest "h1/h2 support for protocol upgrade test"
8
9feature ignore_unknown_macro
10
Christopher Faulet85a81362020-12-15 17:13:39 +010011#REQUIRE_VERSION=2.4
12
Amaury Denoyellebda34302020-12-11 17:53:11 +010013# http/1.1 server
14server srv_h1 {
15 rxreq
16 expect req.method == "GET"
17 expect req.http.connection == "upgrade"
18 expect req.http.upgrade == "custom_protocol"
19
20 txresp \
21 -status 101 \
22 -hdr "connection: upgrade" \
23 -hdr "upgrade: custom_protocol"
24} -repeat 2 -start
25
26# http2 server
27server srv_h2 {
28 rxpri
29
30 stream 0 {
31 txsettings
32 rxsettings
33 txsettings -ack
34 rxsettings
35 expect settings.ack == true
36 } -run
37
38 stream 1 {
39 rxhdrs
40 expect req.method == "CONNECT"
41 expect req.http.:scheme == "https"
42 expect req.http.:path == "/"
43 expect req.http.:authority == "127.0.0.1"
44 expect req.http.:protocol == "custom_protocol"
45
46 txresp \
47 -status 200
48 } -run
49} -repeat 2 -start
50
51haproxy hap -conf {
52 defaults
53 mode http
Amaury Denoyellebda34302020-12-11 17:53:11 +010054 timeout connect 1s
55 timeout client 1s
56 timeout server 1s
57
58 # h1 frontend connected to h2 frontend
59 listen frt_h1_h2
60 bind "fd@${frt_h1_h2}"
61 server feh2_srv ${hap_frt_h2_addr}:${hap_frt_h2_port} proto h2
62
63 # h2 frontend connected to srv_h1
64 listen frt_h2
65 bind "fd@${frt_h2}" proto h2
66 server srv_h1 ${srv_h1_addr}:${srv_h1_port}
67
68 # h1 frontend connected to srv_h2
69 listen frt_h1
70 bind "fd@${frt_h1}"
71 server srv_h2 ${srv_h2_addr}:${srv_h2_port} proto h2
72
73 # h2 frontend connected to h1 frontend
74 listen frt_h2_h1
75 bind "fd@${frt_h2_h1}" proto h2
76 server frt_h1 ${hap_frt_h1_addr}:${hap_frt_h1_port}
77} -start
78
79## connect to h1 translation frontend
80client c1_h1_h2 -connect ${hap_frt_h1_h2_sock} {
81 txreq \
82 -req "GET" \
83 -url "/" \
84 -hdr "host: 127.0.0.1" \
85 -hdr "connection: upgrade" \
86 -hdr "upgrade: custom_protocol"
87
88 rxresp
89 expect resp.status == 101
90 expect resp.http.connection == "upgrade"
91 expect resp.http.upgrade == "custom_protocol"
92} -run
93
94# connect to h2 server frontend
95client c2_h2 -connect ${hap_frt_h2_sock} {
96 txpri
97 stream 0 {
98 txsettings
99 rxsettings
100 txsettings -ack
101 rxsettings
102 expect settings.ack == true
103 } -run
104
105 stream 1 {
106 txreq \
107 -req "CONNECT" \
108 -scheme "http" \
109 -url "/" \
110 -hdr ":authority" "127.0.0.1" \
111 -hdr ":protocol" "custom_protocol"
112
113 rxhdrs
114 expect resp.status == 200
115 } -run
116} -run
117
118# connect to h2 translation frontend
119client c3_h2_h1 -connect ${hap_frt_h2_h1_sock} {
120 txpri
121 stream 0 {
122 txsettings
123 rxsettings
124 txsettings -ack
125 rxsettings
126 expect settings.ack == true
127 } -run
128
129 stream 1 {
130 txreq \
131 -req "CONNECT" \
132 -scheme "http" \
133 -url "/" \
134 -hdr ":authority" "127.0.0.1" \
135 -hdr ":protocol" "custom_protocol"
136
137 rxhdrs
138 expect resp.status == 200
139 } -run
140} -run
141
142# connect to h1 server frontend
143client c4_h1 -connect ${hap_frt_h1_sock} {
144 txreq \
145 -req "GET" \
146 -url "/" \
147 -hdr "host: 127.0.0.1" \
148 -hdr "connection: upgrade" \
149 -hdr "upgrade: custom_protocol"
150
151 rxresp
152 expect resp.status == 101
153 expect resp.http.connection == "upgrade"
154 expect resp.http.upgrade == "custom_protocol"
155} -run