Mercurial > hg > nginx-tests
annotate h2.t @ 738:0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 19 Oct 2015 17:03:04 +0300 |
parents | abf42eb6cf48 |
children | 610e394a6e73 |
rev | line source |
---|---|
646 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for HTTP/2 protocol [RFC7540]. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 use IO::Select; | |
16 use Socket qw/ CRLF /; | |
17 | |
18 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
19 | |
20 use lib 'lib'; | |
21 use Test::Nginx; | |
22 | |
23 ############################################################################### | |
24 | |
25 select STDERR; $| = 1; | |
26 select STDOUT; $| = 1; | |
27 | |
650
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
28 eval { require IO::Socket::SSL; }; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
29 plan(skip_all => 'IO::Socket::SSL not installed') if $@; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
31 plan(skip_all => 'IO::Socket::SSL too old') if $@; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
32 |
646 | 33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) |
650
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
34 ->has(qw/limit_conn rewrite realip shmem/) |
738
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
35 ->has_daemon('openssl')->plan(225); |
704
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
36 |
730
63c45a158cde
Tests: adjusted todo_alerts() in h2.t and spdy.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
729
diff
changeset
|
37 # Some systems have a bug in not treating zero writev iovcnt as EINVAL |
63c45a158cde
Tests: adjusted todo_alerts() in h2.t and spdy.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
729
diff
changeset
|
38 |
63c45a158cde
Tests: adjusted todo_alerts() in h2.t and spdy.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
729
diff
changeset
|
39 $t->todo_alerts() if $^O eq 'darwin'; |
646 | 40 |
41 $t->write_file_expand('nginx.conf', <<'EOF'); | |
42 | |
43 %%TEST_GLOBALS%% | |
44 | |
45 daemon off; | |
46 | |
47 events { | |
48 } | |
49 | |
50 http { | |
51 %%TEST_GLOBALS_HTTP%% | |
52 | |
53 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m; | |
54 limit_conn_zone $binary_remote_addr zone=conn:1m; | |
55 | |
56 server { | |
57 listen 127.0.0.1:8080 http2; | |
58 listen 127.0.0.1:8081; | |
59 listen 127.0.0.1:8082 proxy_protocol http2; | |
60 listen 127.0.0.1:8084 http2 ssl; | |
61 server_name localhost; | |
62 | |
63 ssl_certificate_key localhost.key; | |
64 ssl_certificate localhost.crt; | |
696
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
65 http2_max_field_size 128k; |
698
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
66 http2_max_header_size 128k; |
646 | 67 |
68 location / { | |
69 add_header X-Header X-Foo; | |
70 add_header X-Sent-Foo $http_x_foo; | |
71 add_header X-Referer $http_referer; | |
72 return 200 'body'; | |
73 } | |
74 location /t { | |
75 } | |
76 location /t3.html { | |
77 limit_conn conn 1; | |
78 } | |
79 location /gzip.html { | |
80 gzip on; | |
81 gzip_min_length 0; | |
82 alias %%TESTDIR%%/t2.html; | |
83 } | |
680
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
84 location /frame_size { |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
85 http2_chunk_size 64k; |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
86 alias %%TESTDIR%%/t1.html; |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
87 output_buffers 2 1m; |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
88 } |
696
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
89 location /continuation { |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
90 add_header X-LongHeader $arg_h; |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
91 add_header X-LongHeader $arg_h; |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
92 add_header X-LongHeader $arg_h; |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
93 return 200 body; |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
94 |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
95 location /continuation/204 { |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
96 return 204; |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
97 } |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
98 } |
646 | 99 location /pp { |
100 set_real_ip_from 127.0.0.1/32; | |
101 real_ip_header proxy_protocol; | |
102 alias %%TESTDIR%%/t2.html; | |
103 add_header X-PP $remote_addr; | |
104 } | |
650
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
105 location /h2 { |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
106 return 200 $http2; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
107 } |
716
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
108 location /sp { |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
109 return 200 $server_protocol; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
110 } |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
111 location /scheme { |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
112 return 200 $scheme; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
113 } |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
114 location /https { |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
115 return 200 $https; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
116 } |
651
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
117 location /chunk_size { |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
118 http2_chunk_size 1; |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
119 return 200 'body'; |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
120 } |
646 | 121 location /redirect { |
122 error_page 405 /; | |
123 return 405; | |
124 } | |
125 location /return301 { | |
126 return 301; | |
127 } | |
128 location /return301_absolute { | |
129 return 301 text; | |
130 } | |
131 location /return301_relative { | |
132 return 301 /; | |
133 } | |
134 location /proxy/ { | |
135 add_header X-UC-a $upstream_cookie_a; | |
136 add_header X-UC-c $upstream_cookie_c; | |
137 proxy_pass http://127.0.0.1:8083/; | |
138 proxy_cache NAME; | |
139 proxy_cache_valid 1m; | |
652
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
140 proxy_set_header X-Cookie-a $cookie_a; |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
141 proxy_set_header X-Cookie-c $cookie_c; |
646 | 142 } |
143 location /proxy2/ { | |
144 add_header X-Body "$request_body"; | |
145 proxy_pass http://127.0.0.1:8081/; | |
146 proxy_cache NAME; | |
147 proxy_cache_valid 1m; | |
148 } | |
149 location /proxy_buffering_off { | |
150 proxy_pass http://127.0.0.1:8081/; | |
151 proxy_cache NAME; | |
152 proxy_cache_valid 1m; | |
153 proxy_buffering off; | |
154 } | |
155 location /set-cookie { | |
156 add_header Set-Cookie a=b; | |
157 add_header Set-Cookie c=d; | |
158 return 200; | |
159 } | |
160 location /cookie { | |
161 add_header X-Cookie $http_cookie; | |
162 add_header X-Cookie-a $cookie_a; | |
163 add_header X-Cookie-c $cookie_c; | |
164 return 200; | |
165 } | |
166 } | |
167 | |
168 server { | |
169 listen 127.0.0.1:8085 http2; | |
170 server_name localhost; | |
171 return 200 first; | |
172 } | |
173 | |
174 server { | |
175 listen 127.0.0.1:8085 http2; | |
176 server_name localhost2; | |
177 return 200 second; | |
178 } | |
654
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
179 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
180 server { |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
181 listen 127.0.0.1:8086 http2; |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
182 server_name localhost; |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
183 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
184 http2_max_concurrent_streams 1; |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
185 } |
684
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
186 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
187 server { |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
188 listen 127.0.0.1:8087 http2; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
189 server_name localhost; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
190 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
191 http2_max_field_size 32; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
192 } |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
193 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
194 server { |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
195 listen 127.0.0.1:8088 http2; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
196 server_name localhost; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
197 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
198 http2_max_header_size 64; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
199 } |
714
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
200 |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
201 server { |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
202 listen 127.0.0.1:8089 http2; |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
203 server_name localhost; |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
204 |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
205 http2_recv_timeout 1s; |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
206 } |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
207 |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
208 server { |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
209 listen 127.0.0.1:8090 http2; |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
210 server_name localhost; |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
211 |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
212 http2_idle_timeout 1s; |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
213 } |
646 | 214 } |
215 | |
216 EOF | |
217 | |
218 $t->write_file('openssl.conf', <<EOF); | |
219 [ req ] | |
220 default_bits = 2048 | |
221 encrypt_key = no | |
222 distinguished_name = req_distinguished_name | |
223 [ req_distinguished_name ] | |
224 EOF | |
225 | |
226 my $d = $t->testdir(); | |
227 | |
228 foreach my $name ('localhost') { | |
229 system('openssl req -x509 -new ' | |
230 . "-config '$d/openssl.conf' -subj '/CN=$name/' " | |
231 . "-out '$d/$name.crt' -keyout '$d/$name.key' " | |
232 . ">>$d/openssl.out 2>&1") == 0 | |
233 or die "Can't create certificate for $name: $!\n"; | |
234 } | |
235 | |
236 $t->run_daemon(\&http_daemon); | |
237 $t->run()->waitforsocket('127.0.0.1:8083'); | |
238 | |
239 # file size is slightly beyond initial window size: 2**16 + 80 bytes | |
240 | |
241 $t->write_file('t1.html', | |
242 join('', map { sprintf "X%04dXXX", $_ } (1 .. 8202))); | |
243 $t->write_file('tbig.html', | |
723
bc4d6e2bd031
Tests: adjusted HTTP/2 test to trigger write handler in v2 module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
722
diff
changeset
|
244 join('', map { sprintf "XX%06dXX", $_ } (1 .. 500000))); |
646 | 245 |
246 $t->write_file('t2.html', 'SEE-THIS'); | |
247 $t->write_file('t3.html', 'SEE-THIS'); | |
248 | |
249 my %cframe = ( | |
250 0 => { name => 'DATA', value => \&data }, | |
251 1 => { name => 'HEADERS', value => \&headers }, | |
252 # 2 => { name => 'PRIORITY', value => \&priority }, | |
253 3 => { name => 'RST_STREAM', value => \&rst_stream }, | |
254 4 => { name => 'SETTINGS', value => \&settings }, | |
720 | 255 # 5 => { name => 'PUSH_PROMISE', value => \&push_promise }, |
646 | 256 6 => { name => 'PING', value => \&ping }, |
257 7 => { name => 'GOAWAY', value => \&goaway }, | |
258 8 => { name => 'WINDOW_UPDATE', value => \&window_update }, | |
696
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
259 9 => { name => 'CONTINUATION', value => \&headers }, |
646 | 260 ); |
261 | |
262 ############################################################################### | |
263 | |
738
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
264 # Upgrade mechanism |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
265 |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
266 my $r = http(<<EOF); |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
267 GET / HTTP/1.1 |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
268 Host: localhost |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
269 Connection: Upgrade, HTTP2-Settings |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
270 Upgrade: h2c |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
271 HTTP2-Settings: AAMAAABkAAQAAP__ |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
272 |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
273 EOF |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
274 |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
275 SKIP: { |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
276 skip 'no Upgrade-based negotiation', 2 if $r !~ m!HTTP/1.1 101!; |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
277 |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
278 like($r, qr!Connection: Upgrade!, 'upgrade - connection'); |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
279 like($r, qr!Upgrade: h2c!, 'upgrade - token'); |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
280 |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
281 } |
0881219c0699
Tests: HTTP/2 tests for Upgrade-based negotiation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
737
diff
changeset
|
282 |
646 | 283 # SETTINGS |
284 | |
285 my $sess = new_session(); | |
286 my $frames = h2_read($sess, all => [ | |
287 { type => 'WINDOW_UPDATE' }, | |
288 { type => 'SETTINGS'} | |
289 ]); | |
290 | |
291 my ($frame) = grep { $_->{type} eq 'WINDOW_UPDATE' } @$frames; | |
292 ok($frame, 'WINDOW_UPDATE frame'); | |
293 is($frame->{flags}, 0, 'WINDOW_UPDATE zero flags'); | |
294 is($frame->{sid}, 0, 'WINDOW_UPDATE zero sid'); | |
295 is($frame->{length}, 4, 'WINDOW_UPDATE fixed length'); | |
296 | |
297 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames; | |
298 ok($frame, 'SETTINGS frame'); | |
299 is($frame->{flags}, 0, 'SETTINGS flags'); | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
300 is($frame->{sid}, 0, 'SETTINGS stream'); |
646 | 301 |
302 h2_settings($sess, 1); | |
303 h2_settings($sess, 0); | |
304 | |
305 $frames = h2_read($sess, all => [{ type => 'SETTINGS' }]); | |
306 | |
307 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames; | |
308 ok($frame, 'SETTINGS frame ack'); | |
309 is($frame->{flags}, 1, 'SETTINGS flags ack'); | |
310 | |
311 # PING | |
312 | |
313 h2_ping($sess, 'SEE-THIS'); | |
314 $frames = h2_read($sess, all => [{ type => 'PING' }]); | |
315 | |
316 ($frame) = grep { $_->{type} eq "PING" } @$frames; | |
317 ok($frame, 'PING frame'); | |
318 is($frame->{value}, 'SEE-THIS', 'PING payload'); | |
319 is($frame->{flags}, 1, 'PING flags ack'); | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
320 is($frame->{sid}, 0, 'PING stream'); |
646 | 321 |
714
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
322 # timeouts |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
323 |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
324 push my @sess, new_session(8089); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
325 push @sess, new_session(8089); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
326 h2_ping($sess[-1], 'SEE-THIS'); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
327 push @sess, new_session(8090); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
328 push @sess, new_session(8090); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
329 h2_ping($sess[-1], 'SEE-THIS'); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
330 |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
331 select undef, undef, undef, 2.1; |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
332 |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
333 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
334 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
335 ok($frame, 'recv timeout - new connection GOAWAY'); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
336 is($frame->{code}, 1, 'recv timeout - new connection code'); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
337 |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
338 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
339 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
340 is($frame, undef, 'recv timeout - idle connection GOAWAY'); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
341 |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
342 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
343 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
344 is($frame, undef, 'idle timeout - new connection GOAWAY'); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
345 |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
346 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
347 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
348 ok($frame, 'idle timeout - idle connection GOAWAY'); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
349 is($frame->{code}, 0, 'idle timeout - idle connection code'); |
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
350 |
646 | 351 # GET |
352 | |
714
ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
712
diff
changeset
|
353 $sess = new_session(); |
646 | 354 my $sid = new_stream($sess); |
355 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
356 | |
357 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
358 ok($frame, 'HEADERS frame'); | |
359 is($frame->{sid}, $sid, 'HEADERS stream'); | |
360 is($frame->{headers}->{':status'}, 200, 'HEADERS status'); | |
361 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEADERS header'); | |
362 | |
363 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
364 ok($frame, 'DATA frame'); | |
365 is($frame->{length}, length 'body', 'DATA length'); | |
366 is($frame->{data}, 'body', 'DATA payload'); | |
367 | |
368 # GET in the new stream on same connection | |
369 | |
370 $sid = new_stream($sess); | |
371 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
372 | |
373 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
374 is($frame->{sid}, $sid, 'HEADERS stream 2'); | |
375 is($frame->{headers}->{':status'}, 200, 'HEADERS status 2'); | |
376 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEADERS header 2'); | |
377 | |
378 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
379 ok($frame, 'DATA frame 2'); | |
380 is($frame->{sid}, $sid, 'HEADERS stream 2'); | |
381 is($frame->{length}, length 'body', 'DATA length 2'); | |
382 is($frame->{data}, 'body', 'DATA payload 2'); | |
383 | |
384 # various HEADERS compression/encoding, see hpack() for mode details | |
385 | |
386 # 6.1. Indexed Header Field Representation | |
387 | |
388 $sid = new_stream($sess, { headers => [ | |
389 { name => ':method', value => 'GET', mode => 0 }, | |
390 { name => ':scheme', value => 'http', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
391 { name => ':path', value => '/', mode => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
392 { name => ':authority', value => 'localhost', mode => 1 }]}); |
646 | 393 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
394 | |
395 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
396 is($frame->{headers}->{':status'}, 200, 'indexed header field'); | |
397 | |
398 # 6.2.1. Literal Header Field with Incremental Indexing | |
399 | |
400 $sid = new_stream($sess, { headers => [ | |
401 { name => ':method', value => 'GET', mode => 1, huff => 0 }, | |
402 { name => ':scheme', value => 'http', mode => 1, huff => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
403 { name => ':path', value => '/', mode => 1, huff => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
404 { name => ':authority', value => 'localhost', mode => 1, huff => 0 }]}); |
646 | 405 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
406 | |
407 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
408 is($frame->{headers}->{':status'}, 200, 'literal with indexing'); | |
409 | |
410 $sid = new_stream($sess, { headers => [ | |
411 { name => ':method', value => 'GET', mode => 1, huff => 1 }, | |
412 { name => ':scheme', value => 'http', mode => 1, huff => 1 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
413 { name => ':path', value => '/', mode => 1, huff => 1 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
414 { name => ':authority', value => 'localhost', mode => 1, huff => 1 }]}); |
646 | 415 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
416 | |
417 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
418 is($frame->{headers}->{':status'}, 200, 'literal with indexing - huffman'); | |
419 | |
420 # 6.2.1. Literal Header Field with Incremental Indexing -- New Name | |
421 | |
422 $sid = new_stream($sess, { headers => [ | |
423 { name => ':method', value => 'GET', mode => 2, huff => 0 }, | |
424 { name => ':scheme', value => 'http', mode => 2, huff => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
425 { name => ':path', value => '/', mode => 2, huff => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
426 { name => ':authority', value => 'localhost', mode => 2, huff => 0 }]}); |
646 | 427 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
428 | |
429 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
430 is($frame->{headers}->{':status'}, 200, 'literal with indexing - new'); | |
431 | |
432 $sid = new_stream($sess, { headers => [ | |
433 { name => ':method', value => 'GET', mode => 2, huff => 1 }, | |
434 { name => ':scheme', value => 'http', mode => 2, huff => 1 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
435 { name => ':path', value => '/', mode => 2, huff => 1 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
436 { name => ':authority', value => 'localhost', mode => 2, huff => 1 }]}); |
646 | 437 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
438 | |
439 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
440 is($frame->{headers}->{':status'}, 200, 'literal with indexing - new huffman'); | |
441 | |
442 # 6.2.2. Literal Header Field without Indexing | |
443 | |
444 $sid = new_stream($sess, { headers => [ | |
445 { name => ':method', value => 'GET', mode => 3, huff => 0 }, | |
446 { name => ':scheme', value => 'http', mode => 3, huff => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
447 { name => ':path', value => '/', mode => 3, huff => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
448 { name => ':authority', value => 'localhost', mode => 3, huff => 0 }]}); |
646 | 449 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
450 | |
451 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
452 is($frame->{headers}->{':status'}, 200, 'literal without indexing'); | |
453 | |
454 $sid = new_stream($sess, { headers => [ | |
455 { name => ':method', value => 'GET', mode => 3, huff => 1 }, | |
456 { name => ':scheme', value => 'http', mode => 3, huff => 1 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
457 { name => ':path', value => '/', mode => 3, huff => 1 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
458 { name => ':authority', value => 'localhost', mode => 3, huff => 1 }]}); |
646 | 459 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
460 | |
461 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
462 is($frame->{headers}->{':status'}, 200, 'literal without indexing - huffman'); | |
463 | |
464 # 6.2.2. Literal Header Field without Indexing -- New Name | |
465 | |
466 $sid = new_stream($sess, { headers => [ | |
467 { name => ':method', value => 'GET', mode => 4, huff => 0 }, | |
468 { name => ':scheme', value => 'http', mode => 4, huff => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
469 { name => ':path', value => '/', mode => 4, huff => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
470 { name => ':authority', value => 'localhost', mode => 4, huff => 0 }]}); |
646 | 471 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
472 | |
473 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
474 is($frame->{headers}->{':status'}, 200, 'literal without indexing - new'); | |
475 | |
476 $sid = new_stream($sess, { headers => [ | |
477 { name => ':method', value => 'GET', mode => 4, huff => 1 }, | |
478 { name => ':scheme', value => 'http', mode => 4, huff => 1 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
479 { name => ':path', value => '/', mode => 4, huff => 1 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
480 { name => ':authority', value => 'localhost', mode => 4, huff => 1 }]}); |
646 | 481 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
482 | |
483 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
484 is($frame->{headers}->{':status'}, 200, 'literal without indexing - new huffman'); | |
485 | |
486 # 6.2.3. Literal Header Field Never Indexed | |
487 | |
488 $sid = new_stream($sess, { headers => [ | |
489 { name => ':method', value => 'GET', mode => 5, huff => 0 }, | |
490 { name => ':scheme', value => 'http', mode => 5, huff => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
491 { name => ':path', value => '/', mode => 5, huff => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
492 { name => ':authority', value => 'localhost', mode => 5, huff => 0 }]}); |
646 | 493 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
494 | |
495 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
496 is($frame->{headers}->{':status'}, 200, 'literal never indexed'); | |
497 | |
498 $sid = new_stream($sess, { headers => [ | |
499 { name => ':method', value => 'GET', mode => 5, huff => 1 }, | |
500 { name => ':scheme', value => 'http', mode => 5, huff => 1 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
501 { name => ':path', value => '/', mode => 5, huff => 1 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
502 { name => ':authority', value => 'localhost', mode => 5, huff => 1 }]}); |
646 | 503 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
504 | |
505 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
506 is($frame->{headers}->{':status'}, 200, 'literal never indexed - huffman'); | |
507 | |
508 # 6.2.2. Literal Header Field Never Indexed -- New Name | |
509 | |
510 $sid = new_stream($sess, { headers => [ | |
511 { name => ':method', value => 'GET', mode => 6, huff => 0 }, | |
512 { name => ':scheme', value => 'http', mode => 6, huff => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
513 { name => ':path', value => '/', mode => 6, huff => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
514 { name => ':authority', value => 'localhost', mode => 6, huff => 0 }]}); |
646 | 515 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
516 | |
517 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
518 is($frame->{headers}->{':status'}, 200, 'literal never indexed - new'); | |
519 | |
520 $sid = new_stream($sess, { headers => [ | |
521 { name => ':method', value => 'GET', mode => 6, huff => 1 }, | |
522 { name => ':scheme', value => 'http', mode => 6, huff => 1 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
523 { name => ':path', value => '/', mode => 6, huff => 1 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
524 { name => ':authority', value => 'localhost', mode => 6, huff => 1 }]}); |
646 | 525 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
526 | |
527 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
528 is($frame->{headers}->{':status'}, 200, 'literal never indexed - new huffman'); | |
529 | |
530 # reuse literal with indexing | |
531 | |
532 $sess = new_session(); | |
533 $sid = new_stream($sess, { headers => [ | |
534 { name => ':method', value => 'GET', mode => 0 }, | |
535 { name => ':scheme', value => 'http', mode => 0 }, | |
536 { name => ':path', value => '/', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
537 { name => ':authority', value => 'localhost', mode => 1 }, |
646 | 538 { name => 'referer', value => 'foo', mode => 1 }]}); |
539 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
540 | |
541 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
542 is($frame->{headers}->{'x-referer'}, 'foo', 'value with indexing - new'); | |
543 | |
544 $sid = new_stream($sess, { headers => [ | |
545 { name => ':method', value => 'GET', mode => 0 }, | |
546 { name => ':scheme', value => 'http', mode => 0 }, | |
547 { name => ':path', value => '/', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
548 { name => ':authority', value => 'localhost', mode => 0 }, |
646 | 549 { name => 'referer', value => 'foo', mode => 0 }]}); |
550 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
551 | |
552 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
553 is($frame->{headers}->{'x-referer'}, 'foo', 'value with indexing - indexed'); | |
554 | |
555 $sid = new_stream($sess, { headers => [ | |
556 { name => ':method', value => 'GET', mode => 0 }, | |
557 { name => ':scheme', value => 'http', mode => 0 }, | |
558 { name => ':path', value => '/', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
559 { name => ':authority', value => 'localhost', mode => 0 }, |
646 | 560 { name => 'x-foo', value => 'X-Bar', mode => 2 }]}); |
561 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
562 | |
563 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
564 is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'name with indexing - new'); | |
565 | |
566 # reuse literal with indexing - reused name | |
567 | |
568 $sid = new_stream($sess, { headers => [ | |
569 { name => ':method', value => 'GET', mode => 0 }, | |
570 { name => ':scheme', value => 'http', mode => 0 }, | |
571 { name => ':path', value => '/', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
572 { name => ':authority', value => 'localhost', mode => 0 }, |
646 | 573 { name => 'x-foo', value => 'X-Bar', mode => 0 }]}); |
574 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
575 | |
576 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
577 is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'name with indexing - indexed'); | |
578 | |
737
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
579 # reuse literal with indexing - reused name only |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
580 |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
581 $sid = new_stream($sess, { headers => [ |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
582 { name => ':method', value => 'GET', mode => 0 }, |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
583 { name => ':scheme', value => 'http', mode => 0 }, |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
584 { name => ':path', value => '/', mode => 0 }, |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
585 { name => ':authority', value => 'localhost', mode => 0 }, |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
586 { name => 'x-foo', value => 'X-Baz', mode => 1 }]}); |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
587 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
588 |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
589 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
590 is($frame->{headers}->{'x-sent-foo'}, 'X-Baz', |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
591 'name with indexing - indexed name'); |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
592 |
646 | 593 # 6.3. Dynamic Table Size Update |
594 | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
595 # remove some indexed headers from the dynamic table |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
596 # by maintaining dynamic table space only for index 0 |
646 | 597 # 'x-foo' has index 0, and 'referer' has index 1 |
598 | |
737
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
599 $sess = new_session(); |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
600 $sid = new_stream($sess, { headers => [ |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
601 { name => ':method', value => 'GET', mode => 0 }, |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
602 { name => ':scheme', value => 'http', mode => 0 }, |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
603 { name => ':path', value => '/', mode => 0 }, |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
604 { name => ':authority', value => 'localhost', mode => 1 }, |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
605 { name => 'referer', value => 'foo', mode => 1 }, |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
606 { name => 'x-foo', value => 'X-Bar', mode => 2 }]}); |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
607 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
abf42eb6cf48
Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents:
736
diff
changeset
|
608 |
646 | 609 $sid = new_stream($sess, { table_size => 61, headers => [ |
610 { name => ':method', value => 'GET', mode => 0 }, | |
611 { name => ':scheme', value => 'http', mode => 0 }, | |
612 { name => ':path', value => '/', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
613 { name => 'x-foo', value => 'X-Bar', mode => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
614 { name => ':authority', value => 'localhost', mode => 1 }]}); |
646 | 615 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
616 | |
617 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
618 isnt($frame, undef, 'updated table size - remaining index'); | |
619 | |
620 $sid = new_stream($sess, { headers => [ | |
621 { name => ':method', value => 'GET', mode => 0 }, | |
622 { name => ':scheme', value => 'http', mode => 0 }, | |
623 { name => ':path', value => '/', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
624 { name => ':authority', value => 'localhost', mode => 1 }, |
646 | 625 { name => 'referer', value => 'foo', mode => 0 }]}); |
626 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
627 | |
628 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
672
66f94d6c5047
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
671
diff
changeset
|
629 is($frame, undef, 'invalid index'); |
646 | 630 |
631 # 5.4.1. Connection Error Handling | |
632 # An endpoint that encounters a connection error SHOULD first send a | |
633 # GOAWAY frame <..> | |
634 | |
635 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
672
66f94d6c5047
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
671
diff
changeset
|
636 ok($frame, 'invalid index - GOAWAY'); |
646 | 637 |
691
3f4a132c6463
Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
685
diff
changeset
|
638 # RFC 7541, 2.3.3. Index Address Space |
3f4a132c6463
Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
685
diff
changeset
|
639 # Indices strictly greater than the sum of the lengths of both tables |
3f4a132c6463
Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
685
diff
changeset
|
640 # MUST be treated as a decoding error. |
3f4a132c6463
Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
685
diff
changeset
|
641 |
3f4a132c6463
Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
685
diff
changeset
|
642 # 4.3. Header Compression and Decompression |
3f4a132c6463
Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
685
diff
changeset
|
643 # A decoding error in a header block MUST be treated |
3f4a132c6463
Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
685
diff
changeset
|
644 # as a connection error of type COMPRESSION_ERROR. |
3f4a132c6463
Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
685
diff
changeset
|
645 |
3f4a132c6463
Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
685
diff
changeset
|
646 is($frame->{last_sid}, $sid, 'invalid index - GOAWAY last stream'); |
3f4a132c6463
Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
685
diff
changeset
|
647 is($frame->{code}, 9, 'invalid index - GOAWAY COMPRESSION_ERROR'); |
3f4a132c6463
Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
685
diff
changeset
|
648 |
729
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
649 # invalid table size update |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
650 |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
651 $sess = new_session(); |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
652 $sid = new_stream($sess, { table_size => 4097, headers => [ |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
653 { name => ':method', value => 'GET', mode => 0 }, |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
654 { name => ':scheme', value => 'http', mode => 0 }, |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
655 { name => ':path', value => '/', mode => 0 }, |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
656 { name => 'x-foo', value => 'X-Bar', mode => 0 }, |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
657 { name => ':authority', value => 'localhost', mode => 1 }]}); |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
658 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
659 |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
660 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
661 ok($frame, 'invalid table size - GOAWAY'); |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
662 is($frame->{last_sid}, $sid, 'invalid table size - GOAWAY last stream'); |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
663 is($frame->{code}, 9, 'invalid table size - GOAWAY COMPRESSION_ERROR'); |
41caaaff9b95
Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents:
728
diff
changeset
|
664 |
646 | 665 # HEAD |
666 | |
667 $sess = new_session(); | |
668 $sid = new_stream($sess, { method => 'HEAD' }); | |
669 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]); | |
670 | |
671 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
672 is($frame->{sid}, $sid, 'HEAD - HEADERS'); | |
673 is($frame->{headers}->{':status'}, 200, 'HEAD - HEADERS status'); | |
674 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEAD - HEADERS header'); | |
675 | |
676 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
677 is($frame, undef, 'HEAD - no body'); | |
678 | |
679 # GET with PROXY protocol | |
680 | |
681 my $proxy = 'PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF; | |
682 $sess = new_session(8082, proxy => $proxy); | |
683 $sid = new_stream($sess, { path => '/pp' }); | |
684 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
685 | |
686 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
687 ok($frame, 'PROXY HEADERS frame'); | |
688 is($frame->{headers}->{'x-pp'}, '192.0.2.1', 'PROXY remote addr'); | |
689 | |
690 # range filter | |
691 | |
692 $sess = new_session(); | |
693 $sid = new_stream($sess, { headers => [ | |
694 { name => ':method', value => 'GET', mode => 0 }, | |
695 { name => ':scheme', value => 'http', mode => 0 }, | |
696 { name => ':path', value => '/t1.html', mode => 1 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
697 { name => ':authority', value => 'localhost', mode => 1 }, |
646 | 698 { name => 'range', value => 'bytes=10-19', mode => 1 }]}); |
699 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
700 | |
701 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
702 is($frame->{headers}->{':status'}, 206, 'range - HEADERS status'); | |
703 | |
704 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
705 is($frame->{length}, 10, 'range - DATA length'); | |
706 is($frame->{data}, '002XXXX000', 'range - DATA payload'); | |
707 | |
650
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
708 # $http2 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
709 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
710 $sess = new_session(); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
711 $sid = new_stream($sess, { path => '/h2' }); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
712 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
713 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
714 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
715 is($frame->{data}, 'h2c', 'http variable - h2c'); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
716 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
717 # SSL/TLS connection, NPN |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
718 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
719 SKIP: { |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
720 eval { IO::Socket::SSL->can_npn() or die; }; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
721 skip 'OpenSSL NPN support required', 1 if $@; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
722 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
723 $sess = new_session(8084, SSL => 1, npn => 'h2'); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
724 $sid = new_stream($sess, { path => '/h2' }); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
725 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
726 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
727 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
728 is($frame->{data}, 'h2', 'http variable - npn'); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
729 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
730 } |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
731 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
732 # SSL/TLS connection, ALPN |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
733 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
734 SKIP: { |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
735 eval { IO::Socket::SSL->can_alpn() or die; }; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
736 skip 'OpenSSL ALPN support required', 1 if $@; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
737 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
738 $sess = new_session(8084, SSL => 1, alpn => 'h2'); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
739 $sid = new_stream($sess, { path => '/h2' }); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
740 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
741 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
742 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
743 is($frame->{data}, 'h2', 'http variable - alpn'); |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
744 |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
745 } |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
746 |
716
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
747 # $server_protocol |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
748 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
749 $sess = new_session(); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
750 $sid = new_stream($sess, { path => '/sp' }); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
751 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
752 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
753 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
754 is($frame->{data}, 'HTTP/2.0', 'server_protocol variable'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
755 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
756 # $server_protocol - SSL/TLS connection, NPN |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
757 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
758 SKIP: { |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
759 eval { IO::Socket::SSL->can_npn() or die; }; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
760 skip 'OpenSSL NPN support required', 1 if $@; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
761 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
762 $sess = new_session(8084, SSL => 1, npn => 'h2'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
763 $sid = new_stream($sess, { path => '/sp' }); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
764 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
765 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
766 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
767 is($frame->{data}, 'HTTP/2.0', 'server_protocol variable - npn'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
768 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
769 } |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
770 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
771 # $server_protocol - SSL/TLS connection, ALPN |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
772 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
773 SKIP: { |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
774 eval { IO::Socket::SSL->can_alpn() or die; }; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
775 skip 'OpenSSL ALPN support required', 1 if $@; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
776 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
777 $sess = new_session(8084, SSL => 1, alpn => 'h2'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
778 $sid = new_stream($sess, { path => '/sp' }); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
779 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
780 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
781 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
782 is($frame->{data}, 'HTTP/2.0', 'server_protocol variable - alpn'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
783 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
784 } |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
785 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
786 # $scheme |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
787 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
788 $sess = new_session(); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
789 $sid = new_stream($sess, { path => '/scheme' }); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
790 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
791 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
792 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
793 is($frame->{data}, 'http', 'scheme variable'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
794 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
795 # $scheme - SSL/TLS connection, NPN |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
796 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
797 SKIP: { |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
798 eval { IO::Socket::SSL->can_npn() or die; }; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
799 skip 'OpenSSL NPN support required', 1 if $@; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
800 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
801 $sess = new_session(8084, SSL => 1, npn => 'h2'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
802 $sid = new_stream($sess, { path => '/scheme' }); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
803 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
804 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
805 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
806 is($frame->{data}, 'https', 'scheme variable - npn'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
807 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
808 } |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
809 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
810 # $scheme - SSL/TLS connection, ALPN |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
811 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
812 SKIP: { |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
813 eval { IO::Socket::SSL->can_alpn() or die; }; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
814 skip 'OpenSSL ALPN support required', 1 if $@; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
815 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
816 $sess = new_session(8084, SSL => 1, alpn => 'h2'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
817 $sid = new_stream($sess, { path => '/scheme' }); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
818 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
819 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
820 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
821 is($frame->{data}, 'https', 'scheme variable - alpn'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
822 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
823 } |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
824 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
825 # $https |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
826 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
827 $sess = new_session(); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
828 $sid = new_stream($sess, { path => '/https' }); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
829 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
830 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
831 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
832 is($frame->{data}, '', 'https variable'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
833 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
834 # $https - SSL/TLS connection, NPN |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
835 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
836 SKIP: { |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
837 eval { IO::Socket::SSL->can_npn() or die; }; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
838 skip 'OpenSSL NPN support required', 1 if $@; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
839 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
840 $sess = new_session(8084, SSL => 1, npn => 'h2'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
841 $sid = new_stream($sess, { path => '/https' }); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
842 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
843 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
844 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
845 is($frame->{data}, 'on', 'https variable - npn'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
846 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
847 } |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
848 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
849 # $https - SSL/TLS connection, ALPN |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
850 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
851 SKIP: { |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
852 eval { IO::Socket::SSL->can_alpn() or die; }; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
853 skip 'OpenSSL ALPN support required', 1 if $@; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
854 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
855 $sess = new_session(8084, SSL => 1, alpn => 'h2'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
856 $sid = new_stream($sess, { path => '/https' }); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
857 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
858 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
859 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
860 is($frame->{data}, 'on', 'https variable - alpn'); |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
861 |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
862 } |
e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
715
diff
changeset
|
863 |
651
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
864 # http2_chunk_size=1 |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
865 |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
866 $sess = new_session(); |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
867 $sid = new_stream($sess, { path => '/chunk_size' }); |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
868 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
869 |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
870 my @data = grep { $_->{type} eq "DATA" } @$frames; |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
871 is(@data, 4, 'chunk_size frames'); |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
872 is(join(' ', map { $_->{data} } @data), 'b o d y', 'chunk_size data'); |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
873 is(join(' ', map { $_->{flags} } @data), '0 0 0 1', 'chunk_size flags'); |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
874 |
646 | 875 # CONTINUATION |
876 | |
650
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
877 $sess = new_session(); |
646 | 878 $sid = new_stream($sess, { continuation => 1, headers => [ |
879 { name => ':method', value => 'HEAD', mode => 1 }, | |
880 { name => ':scheme', value => 'http', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
881 { name => ':path', value => '/', mode => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
882 { name => ':authority', value => 'localhost', mode => 1 }]}); |
646 | 883 h2_continue($sess, $sid, { continuation => 1, headers => [ |
884 { name => 'x-foo', value => 'X-Bar', mode => 2 }]}); | |
885 h2_continue($sess, $sid, { headers => [ | |
886 { name => 'referer', value => 'foo', mode => 2 }]}); | |
887 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
888 | |
889 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
890 is($frame, undef, 'CONTINUATION - fragment 1'); | |
891 | |
892 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
893 is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'CONTINUATION - fragment 2'); | |
894 is($frame->{headers}->{'x-referer'}, 'foo', 'CONTINUATION - fragment 3'); | |
895 | |
699
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
896 # CONTINUATION - in the middle of request header field |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
897 |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
898 $sess = new_session(); |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
899 $sid = new_stream($sess, { continuation => [ 2, 4, 1, 5 ], headers => [ |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
900 { name => ':method', value => 'HEAD', mode => 1 }, |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
901 { name => ':scheme', value => 'http', mode => 0 }, |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
902 { name => ':path', value => '/', mode => 0 }, |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
903 { name => ':authority', value => 'localhost', mode => 1 }]}); |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
904 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
905 |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
906 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
907 is($frame->{headers}->{':status'}, 200, 'CONTINUATION - in header field'); |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
908 |
646 | 909 # frame padding |
910 | |
911 $sess = new_session(); | |
912 $sid = new_stream($sess, { padding => 42, headers => [ | |
913 { name => ':method', value => 'GET', mode => 0 }, | |
914 { name => ':scheme', value => 'http', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
915 { name => ':path', value => '/', mode => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
916 { name => ':authority', value => 'localhost', mode => 1 }]}); |
646 | 917 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
918 | |
919 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
920 is($frame->{headers}->{':status'}, 200, 'padding - HEADERS status'); | |
921 | |
922 $sid = new_stream($sess, { headers => [ | |
923 { name => ':method', value => 'GET', mode => 0 }, | |
924 { name => ':scheme', value => 'http', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
925 { name => ':path', value => '/', mode => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
926 { name => ':authority', value => 'localhost', mode => 1 }]}); |
646 | 927 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
928 | |
929 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
930 is($frame->{headers}->{':status'}, 200, 'padding - next stream'); | |
931 | |
932 # request header field with multiple values | |
933 | |
934 # 8.1.2.5. Compressing the Cookie Header Field | |
935 # To allow for better compression efficiency, the Cookie header field | |
936 # MAY be split into separate header fields <..>. | |
937 | |
938 $sess = new_session(); | |
939 $sid = new_stream($sess, { headers => [ | |
940 { name => ':method', value => 'GET', mode => 0 }, | |
941 { name => ':scheme', value => 'http', mode => 0 }, | |
942 { name => ':path', value => '/cookie', mode => 2 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
943 { name => ':authority', value => 'localhost', mode => 1 }, |
646 | 944 { name => 'cookie', value => 'a=b', mode => 2}, |
945 { name => 'cookie', value => 'c=d', mode => 2}]}); | |
946 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
947 | |
948 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
949 is($frame->{headers}->{'x-cookie-a'}, 'b', | |
950 'multiple request header fields - cookie'); | |
951 is($frame->{headers}->{'x-cookie-c'}, 'd', | |
952 'multiple request header fields - cookie 2'); | |
953 is($frame->{headers}->{'x-cookie'}, 'a=b; c=d', | |
954 'multiple request header fields - semi-colon'); | |
955 | |
956 # request header field with multiple values to HTTP backend | |
957 | |
958 # 8.1.2.5. Compressing the Cookie Header Field | |
959 # these MUST be concatenated into a single octet string | |
960 # using the two-octet delimiter of 0x3B, 0x20 (the ASCII string "; ") | |
961 # before being passed into a non-HTTP/2 context, such as an HTTP/1.1 | |
962 # connection <..> | |
963 | |
964 $sess = new_session(); | |
965 $sid = new_stream($sess, { headers => [ | |
966 { name => ':method', value => 'GET', mode => 0 }, | |
967 { name => ':scheme', value => 'http', mode => 0 }, | |
968 { name => ':path', value => '/proxy/cookie', mode => 2 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
969 { name => ':authority', value => 'localhost', mode => 1 }, |
646 | 970 { name => 'cookie', value => 'a=b', mode => 2 }, |
971 { name => 'cookie', value => 'c=d', mode => 2 }]}); | |
972 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
973 | |
974 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
652
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
975 is($frame->{headers}->{'x-sent-cookie'}, 'a=b; c=d', |
646 | 976 'multiple request header fields proxied - semi-colon'); |
652
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
977 is($frame->{headers}->{'x-sent-cookie2'}, '', |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
978 'multiple request header fields proxied - dublicate cookie'); |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
979 is($frame->{headers}->{'x-sent-cookie-a'}, 'b', |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
980 'multiple request header fields proxied - cookie 1'); |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
981 is($frame->{headers}->{'x-sent-cookie-c'}, 'd', |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
982 'multiple request header fields proxied - cookie 2'); |
646 | 983 |
984 # response header field with multiple values | |
985 | |
986 $sess = new_session(); | |
987 $sid = new_stream($sess, { path => '/set-cookie' }); | |
988 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
989 | |
990 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
991 is($frame->{headers}->{'set-cookie'}[0], 'a=b', | |
992 'multiple response header fields - cookie'); | |
993 is($frame->{headers}->{'set-cookie'}[1], 'c=d', | |
994 'multiple response header fields - cookie 2'); | |
995 | |
996 # response header field with multiple values from HTTP backend | |
997 | |
998 $sess = new_session(); | |
999 $sid = new_stream($sess, { path => '/proxy/set-cookie' }); | |
1000 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1001 | |
1002 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1003 is($frame->{headers}->{'set-cookie'}[0], 'a=b', | |
1004 'multiple response header proxied - cookie'); | |
1005 is($frame->{headers}->{'set-cookie'}[1], 'c=d', | |
1006 'multiple response header proxied - cookie 2'); | |
1007 is($frame->{headers}->{'x-uc-a'}, 'b', | |
1008 'multiple response header proxied - upstream cookie'); | |
1009 is($frame->{headers}->{'x-uc-c'}, 'd', | |
1010 'multiple response header proxied - upstream cookie 2'); | |
1011 | |
1012 # internal redirect | |
1013 | |
1014 $sess = new_session(); | |
1015 $sid = new_stream($sess, { path => '/redirect' }); | |
1016 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1017 | |
1018 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1019 is($frame->{headers}->{':status'}, 405, 'redirect - HEADERS'); | |
1020 | |
1021 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
1022 ok($frame, 'redirect - DATA'); | |
1023 is($frame->{data}, 'body', 'redirect - DATA payload'); | |
1024 | |
1025 # return 301 with absolute URI | |
1026 | |
1027 $sess = new_session(); | |
1028 $sid = new_stream($sess, { path => '/return301_absolute' }); | |
1029 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1030 | |
1031 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1032 is($frame->{headers}->{':status'}, 301, 'return 301 absolute - status'); | |
1033 is($frame->{headers}->{'location'}, 'text', 'return 301 absolute - location'); | |
1034 | |
1035 # return 301 with relative URI | |
1036 | |
1037 $sess = new_session(); | |
1038 $sid = new_stream($sess, { path => '/return301_relative' }); | |
1039 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1040 | |
1041 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1042 is($frame->{headers}->{':status'}, 301, 'return 301 relative - status'); | |
1043 is($frame->{headers}->{'location'}, 'http://127.0.0.1:8080/', | |
1044 'return 301 relative - location'); | |
1045 | |
1046 # return 301 with relative URI and ':authority' request header field | |
1047 | |
1048 $sess = new_session(); | |
1049 $sid = new_stream($sess, { headers => [ | |
1050 { name => ':method', value => 'GET', mode => 0 }, | |
1051 { name => ':scheme', value => 'http', mode => 0 }, | |
1052 { name => ':path', value => '/return301_relative', mode => 2 }, | |
1053 { name => ':authority', value => 'localhost', mode => 2 }]}); | |
1054 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1055 | |
1056 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1057 is($frame->{headers}->{':status'}, 301, | |
1058 'return 301 relative - authority - status'); | |
1059 is($frame->{headers}->{'location'}, 'http://localhost:8080/', | |
1060 'return 301 relative - authority - location'); | |
1061 | |
1062 # return 301 with relative URI and 'host' request header field | |
1063 | |
1064 $sess = new_session(); | |
1065 $sid = new_stream($sess, { headers => [ | |
1066 { name => ':method', value => 'GET', mode => 0 }, | |
1067 { name => ':scheme', value => 'http', mode => 0 }, | |
1068 { name => ':path', value => '/return301_relative', mode => 2 }, | |
1069 { name => 'host', value => 'localhost', mode => 2 }]}); | |
1070 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1071 | |
1072 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1073 is($frame->{headers}->{':status'}, 301, | |
1074 'return 301 relative - host - status'); | |
1075 is($frame->{headers}->{'location'}, 'http://localhost:8080/', | |
1076 'return 301 relative - host - location'); | |
1077 | |
1078 # virtual host | |
1079 | |
1080 $sess = new_session(8085); | |
1081 $sid = new_stream($sess, { headers => [ | |
1082 { name => ':method', value => 'GET', mode => 0 }, | |
1083 { name => ':scheme', value => 'http', mode => 0 }, | |
1084 { name => ':path', value => '/', mode => 0 }, | |
1085 { name => 'host', value => 'localhost', mode => 2 }]}); | |
1086 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1087 | |
1088 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1089 is($frame->{headers}->{':status'}, 200, | |
1090 'virtual host - host - status'); | |
1091 | |
1092 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
1093 is($frame->{data}, 'first', 'virtual host - host - DATA'); | |
1094 | |
1095 $sid = new_stream($sess, { headers => [ | |
1096 { name => ':method', value => 'GET', mode => 0 }, | |
1097 { name => ':scheme', value => 'http', mode => 0 }, | |
1098 { name => ':path', value => '/', mode => 0 }, | |
1099 { name => ':authority', value => 'localhost', mode => 2 }]}); | |
1100 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1101 | |
1102 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1103 is($frame->{headers}->{':status'}, 200, | |
1104 'virtual host - authority - status'); | |
1105 | |
1106 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
1107 is($frame->{data}, 'first', 'virtual host - authority - DATA'); | |
1108 | |
1109 # virtual host - second | |
1110 | |
1111 $sid = new_stream($sess, { headers => [ | |
1112 { name => ':method', value => 'GET', mode => 0 }, | |
1113 { name => ':scheme', value => 'http', mode => 0 }, | |
1114 { name => ':path', value => '/', mode => 0 }, | |
1115 { name => 'host', value => 'localhost2', mode => 2 }]}); | |
1116 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1117 | |
1118 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1119 is($frame->{headers}->{':status'}, 200, | |
1120 'virtual host 2 - host - status'); | |
1121 | |
1122 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
1123 is($frame->{data}, 'second', 'virtual host 2 - host - DATA'); | |
1124 | |
1125 $sid = new_stream($sess, { headers => [ | |
1126 { name => ':method', value => 'GET', mode => 0 }, | |
1127 { name => ':scheme', value => 'http', mode => 0 }, | |
1128 { name => ':path', value => '/', mode => 0 }, | |
1129 { name => ':authority', value => 'localhost2', mode => 2 }]}); | |
1130 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1131 | |
1132 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1133 is($frame->{headers}->{':status'}, 200, | |
1134 'virtual host 2 - authority - status'); | |
1135 | |
1136 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
1137 is($frame->{data}, 'second', 'virtual host 2 - authority - DATA'); | |
1138 | |
1139 # gzip tests for internal nginx version | |
1140 | |
1141 $sess = new_session(); | |
1142 $sid = new_stream($sess, { headers => [ | |
1143 { name => ':method', value => 'GET', mode => 0 }, | |
1144 { name => ':scheme', value => 'http', mode => 0 }, | |
1145 { name => ':path', value => '/gzip.html' }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
1146 { name => ':authority', value => 'localhost', mode => 1 }, |
646 | 1147 { name => 'accept-encoding', value => 'gzip' }]}); |
1148 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1149 | |
1150 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1151 is($frame->{headers}->{'content-encoding'}, 'gzip', 'gzip - encoding'); | |
1152 | |
1153 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
647
4e36550410b3
Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
646
diff
changeset
|
1154 gunzip_like($frame->{data}, qr/^SEE-THIS\Z/, 'gzip - DATA'); |
646 | 1155 |
1156 # simple proxy cache test | |
1157 | |
1158 $sess = new_session(); | |
1159 $sid = new_stream($sess, { path => '/proxy2/t2.html?2' }); | |
1160 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1161 | |
1162 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1163 is($frame->{headers}->{':status'}, '200', 'proxy cache'); | |
1164 | |
1165 my $etag = $frame->{headers}->{'etag'}; | |
1166 | |
1167 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
1168 is($frame->{length}, length 'SEE-THIS', 'proxy cache - DATA'); | |
1169 is($frame->{data}, 'SEE-THIS', 'proxy cache - DATA payload'); | |
1170 | |
1171 $sid = new_stream($sess, { headers => [ | |
1172 { name => ':method', value => 'GET', mode => 0 }, | |
1173 { name => ':scheme', value => 'http', mode => 0 }, | |
1174 { name => ':path', value => '/proxy2/t2.html?2' }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
1175 { name => ':authority', value => 'localhost', mode => 1 }, |
646 | 1176 { name => 'if-none-match', value => $etag }]}); |
1177 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1178 | |
1179 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1180 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional'); | |
1181 | |
1182 # HEADERS could be received with fin, followed by DATA | |
1183 | |
1184 $sess = new_session(); | |
1185 $sid = new_stream($sess, { path => '/proxy2/t2.html', method => 'HEAD' }); | |
1186 | |
1187 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1188 push @$frames, $_ for @{h2_read($sess, all => [{ sid => $sid }])}; | |
1189 ok(!grep ({ $_->{type} eq "DATA" } @$frames), 'proxy cache HEAD - no body'); | |
1190 | |
1191 # HEAD on empty cache with proxy_buffering off | |
1192 | |
1193 $sess = new_session(); | |
1194 $sid = new_stream($sess, | |
1195 { path => '/proxy_buffering_off/t2.html?1', method => 'HEAD' }); | |
1196 | |
1197 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1198 push @$frames, $_ for @{h2_read($sess, all => [{ sid => $sid }])}; | |
1199 ok(!grep ({ $_->{type} eq "DATA" } @$frames), | |
1200 'proxy cache HEAD buffering off - no body'); | |
1201 | |
1202 # request body (uses proxied response) | |
1203 | |
1204 $sess = new_session(); | |
1205 $sid = new_stream($sess, { path => '/proxy2/t2.html', body => 'TEST' }); | |
1206 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1207 | |
1208 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1209 is($frame->{headers}->{'x-body'}, 'TEST', 'request body'); | |
1210 | |
1211 # request body with padding (uses proxied response) | |
1212 | |
1213 $sess = new_session(); | |
1214 $sid = new_stream($sess, | |
1215 { path => '/proxy2/t2.html', body => 'TEST', body_padding => 42 }); | |
1216 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1217 | |
1218 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1219 is($frame->{headers}->{'x-body'}, 'TEST', 'request body with padding'); | |
1220 | |
1221 $sid = new_stream($sess); | |
1222 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1223 | |
1224 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1225 is($frame->{headers}->{':status'}, '200', 'request body with padding - next'); | |
1226 | |
1227 # initial window size, client side | |
1228 | |
1229 # 6.9.2. Initial Flow-Control Window Size | |
1230 # When an HTTP/2 connection is first established, new streams are | |
1231 # created with an initial flow-control window size of 65,535 octets. | |
1232 # The connection flow-control window is also 65,535 octets. | |
1233 | |
1234 $sess = new_session(); | |
1235 $sid = new_stream($sess, { path => '/t1.html' }); | |
1236 $frames = h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1237 | |
1238 # with the default http2_chunk_size, data is divided into 8 data frames | |
1239 | |
651
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
1240 @data = grep { $_->{type} eq "DATA" } @$frames; |
646 | 1241 my $lengths = join ' ', map { $_->{length} } @data; |
1242 is($lengths, '8192 8192 8192 8192 8192 8192 8192 8191', | |
1243 'iws - stream blocked on initial window size'); | |
1244 | |
1245 h2_ping($sess, 'SEE-THIS'); | |
1246 $frames = h2_read($sess, all => [{ type => 'PING' }]); | |
1247 | |
1248 ($frame) = grep { $_->{type} eq "PING" && $_->{flags} & 0x1 } @$frames; | |
1249 ok($frame, 'iws - PING not blocked'); | |
1250 | |
1251 h2_window($sess, 2**16, $sid); | |
1252 $frames = h2_read($sess); | |
1253 is(@$frames, 0, 'iws - updated stream window'); | |
1254 | |
1255 h2_window($sess, 2**16); | |
1256 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1257 | |
1258 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1259 my $sum = eval join '+', map { $_->{length} } @data; | |
1260 is($sum, 81, 'iws - updated connection window'); | |
1261 | |
1262 # SETTINGS (initial window size, client side) | |
1263 | |
1264 # 6.9.2. Initial Flow-Control Window Size | |
1265 # Both endpoints can adjust the initial window size for new streams by | |
1266 # including a value for SETTINGS_INITIAL_WINDOW_SIZE in the SETTINGS | |
1267 # frame that forms part of the connection preface. The connection | |
1268 # flow-control window can only be changed using WINDOW_UPDATE frames. | |
1269 | |
1270 $sess = new_session(); | |
1271 h2_settings($sess, 0, 0x4 => 2**17); | |
1272 h2_window($sess, 2**17); | |
1273 | |
1274 $sid = new_stream($sess, { path => '/t1.html' }); | |
1275 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1276 | |
1277 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1278 $sum = eval join '+', map { $_->{length} } @data; | |
1279 is($sum, 2**16 + 80, 'iws - increased'); | |
1280 | |
1281 # probe for negative available space in a flow control window | |
1282 | |
1283 # 6.9.2. Initial Flow-Control Window Size | |
1284 # A change to SETTINGS_INITIAL_WINDOW_SIZE can cause the available | |
1285 # space in a flow-control window to become negative. A sender MUST | |
1286 # track the negative flow-control window and MUST NOT send new flow- | |
1287 # controlled frames until it receives WINDOW_UPDATE frames that cause | |
1288 # the flow-control window to become positive. | |
1289 | |
1290 $sess = new_session(); | |
1291 $sid = new_stream($sess, { path => '/t1.html' }); | |
1292 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1293 | |
1294 h2_window($sess, 1); | |
1295 h2_settings($sess, 0, 0x4 => 42); | |
1296 h2_window($sess, 1024, $sid); | |
1297 | |
1298 $frames = h2_read($sess, all => [{ type => 'SETTINGS' }]); | |
1299 | |
1300 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames; | |
1301 ok($frame, 'negative window - SETTINGS frame ack'); | |
1302 is($frame->{flags}, 1, 'negative window - SETTINGS flags ack'); | |
1303 | |
1304 ($frame) = grep { $_->{type} ne 'SETTINGS' } @$frames; | |
1305 is($frame, undef, 'negative window - no data'); | |
1306 | |
1307 # predefined window size, minus new iws settings, minus window update | |
1308 | |
1309 h2_window($sess, 2**16 - 1 - 42 - 1024, $sid); | |
1310 | |
1311 $frames = h2_read($sess); | |
1312 is(@$frames, 0, 'zero window - no data'); | |
1313 | |
1314 h2_window($sess, 1, $sid); | |
1315 | |
1316 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]); | |
1317 is(@$frames, 1, 'positive window'); | |
712
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
1318 |
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
1319 SKIP: { |
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
1320 skip 'failed connection', 2 unless @$frames; |
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
1321 |
646 | 1322 is(@$frames[0]->{type}, 'DATA', 'positive window - data'); |
1323 is(@$frames[0]->{length}, 1, 'positive window - data length'); | |
1324 | |
712
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
1325 } |
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
1326 |
704
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1327 # ask write handler in sending large response |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1328 |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1329 $sid = new_stream($sess, { path => '/tbig.html' }); |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1330 |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1331 h2_window($sess, 2**30, $sid); |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1332 h2_window($sess, 2**30); |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1333 |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1334 sleep 1; |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1335 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1336 |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1337 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1338 is($frame->{headers}->{':status'}, 200, 'large response - HEADERS'); |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1339 |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1340 @data = grep { $_->{type} eq "DATA" } @$frames; |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1341 $sum = eval join '+', map { $_->{length} } @data; |
723
bc4d6e2bd031
Tests: adjusted HTTP/2 test to trigger write handler in v2 module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
722
diff
changeset
|
1342 is($sum, 5000000, 'large response - DATA'); |
704
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
1343 |
680
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1344 # SETTINGS_MAX_FRAME_SIZE |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1345 |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1346 $sess = new_session(); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1347 $sid = new_stream($sess, { path => '/frame_size' }); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1348 h2_window($sess, 2**18, 1); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1349 h2_window($sess, 2**18); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1350 |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1351 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1352 @data = grep { $_->{type} eq "DATA" } @$frames; |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1353 is($data[0]->{length}, 2**14, 'max frame size - default'); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1354 |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1355 $sess = new_session(); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1356 h2_settings($sess, 0, 0x5 => 2**15); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1357 $sid = new_stream($sess, { path => '/frame_size' }); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1358 h2_window($sess, 2**18, 1); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1359 h2_window($sess, 2**18); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1360 |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1361 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1362 @data = grep { $_->{type} eq "DATA" } @$frames; |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1363 is($data[0]->{length}, 2**15, 'max frame size - custom'); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
1364 |
696
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1365 # CONTINUATION in response |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1366 # put three long header fields (not less than SETTINGS_MAX_FRAME_SIZE/2) |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1367 # to break header block into separate frames, one such field per frame |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1368 |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1369 $sess = new_session(); |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1370 $sid = new_stream($sess, { path => '/continuation?h=' . 'x' x 2**13 }); |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1371 |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1372 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]); |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1373 @data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames; |
718
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1374 is(@{$data[-1]->{headers}{'x-longheader'}}, 3, |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1375 'response CONTINUATION - headers'); |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1376 is($data[-1]->{headers}{'x-longheader'}[0], 'x' x 2**13, |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1377 'response CONTINUATION - header 1'); |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1378 is($data[-1]->{headers}{'x-longheader'}[1], 'x' x 2**13, |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1379 'response CONTINUATION - header 2'); |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1380 is($data[-1]->{headers}{'x-longheader'}[2], 'x' x 2**13, |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1381 'response CONTINUATION - header 3'); |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1382 @data = sort { $a <=> $b } map { $_->{length} } @data; |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1383 cmp_ok($data[-1], '<=', 2**14, 'response CONTINUATION - max frame size'); |
696
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1384 |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1385 # same but without response DATA frames |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1386 |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1387 $sess = new_session(); |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1388 $sid = new_stream($sess, { path => '/continuation/204?h=' . 'x' x 2**13 }); |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1389 |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1390 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]); |
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1391 @data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames; |
718
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1392 is(@{$data[-1]->{headers}{'x-longheader'}}, 3, |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1393 'no body CONTINUATION - headers'); |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1394 is($data[-1]->{headers}{'x-longheader'}[0], 'x' x 2**13, |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1395 'no body CONTINUATION - header 1'); |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1396 is($data[-1]->{headers}{'x-longheader'}[1], 'x' x 2**13, |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1397 'no body CONTINUATION - header 2'); |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1398 is($data[-1]->{headers}{'x-longheader'}[2], 'x' x 2**13, |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1399 'no body CONTINUATION - header 3'); |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1400 @data = sort { $a <=> $b } map { $_->{length} } @data; |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
1401 cmp_ok($data[-1], '<=', 2**14, 'no body CONTINUATION - max frame size'); |
696
beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
694
diff
changeset
|
1402 |
698
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1403 # response header block is always split by SETTINGS_MAX_FRAME_SIZE |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1404 |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1405 TODO: { |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1406 local $TODO = 'not yet'; |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1407 |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1408 $sess = new_session(); |
719
91bedf9d60a7
Tests: adjusted field length in HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
718
diff
changeset
|
1409 $sid = new_stream($sess, { path => '/continuation?h=' . 'x' x 2**15 }); |
698
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1410 |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1411 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]); |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1412 @data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames; |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1413 @data = sort { $a <=> $b } map { $_->{length} } @data; |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1414 cmp_ok($data[-1], '<=', 2**14, 'response header frames limited'); |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1415 |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1416 } |
f86c8314d205
Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
697
diff
changeset
|
1417 |
684
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1418 # max_field_size |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1419 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1420 $sess = new_session(8087); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1421 $sid = new_stream($sess, { headers => [ |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1422 { name => ':method', value => 'GET', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1423 { name => ':scheme', value => 'http', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1424 { name => ':path', value => '/t2.html', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1425 { name => ':authority', value => 'localhost', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1426 { name => 'longname10', value => 'valu5' x 4 . 'x', mode => 2 }]}); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1427 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1428 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1429 ($frame) = grep { $_->{type} eq 'DATA' } @$frames; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1430 ok($frame, 'field size less'); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1431 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1432 $sid = new_stream($sess, { headers => [ |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1433 { name => ':method', value => 'GET', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1434 { name => ':scheme', value => 'http', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1435 { name => ':path', value => '/t2.html', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1436 { name => ':authority', value => 'localhost', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1437 { name => 'longname10', value => 'valu5' x 4 . 'x', mode => 2 }]}); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1438 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1439 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1440 ($frame) = grep { $_->{type} eq 'DATA' } @$frames; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1441 ok($frame, 'field size second'); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1442 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1443 $sess = new_session(8087); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1444 $sid = new_stream($sess, { headers => [ |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1445 { name => ':method', value => 'GET', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1446 { name => ':scheme', value => 'http', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1447 { name => ':path', value => '/t2.html', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1448 { name => ':authority', value => 'localhost', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1449 { name => 'longname10', value => 'valu5' x 4 . 'xx', mode => 2 }]}); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1450 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1451 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1452 ($frame) = grep { $_->{type} eq 'DATA' } @$frames; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1453 ok($frame, 'field size equal'); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1454 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1455 $sess = new_session(8087); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1456 $sid = new_stream($sess, { headers => [ |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1457 { name => ':method', value => 'GET', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1458 { name => ':scheme', value => 'http', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1459 { name => ':path', value => '/t2.html', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1460 { name => ':authority', value => 'localhost', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1461 { name => 'longname10', value => 'valu5' x 4 . 'xxx', mode => 2 }]}); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1462 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1463 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1464 ($frame) = grep { $_->{type} eq 'DATA' } @$frames; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1465 is($frame, undef, 'field size greater'); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1466 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1467 # max_header_size |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1468 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1469 $sess = new_session(8088); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1470 $sid = new_stream($sess, { headers => [ |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1471 { name => ':method', value => 'GET', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1472 { name => ':scheme', value => 'http', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1473 { name => ':path', value => '/t2.html', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1474 { name => ':authority', value => 'localhost', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1475 { name => 'longname9', value => 'x', mode => 2 }]}); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1476 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1477 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1478 ($frame) = grep { $_->{type} eq 'DATA' } @$frames; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1479 ok($frame, 'header size less'); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1480 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1481 $sid = new_stream($sess, { headers => [ |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1482 { name => ':method', value => 'GET', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1483 { name => ':scheme', value => 'http', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1484 { name => ':path', value => '/t2.html', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1485 { name => ':authority', value => 'localhost', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1486 { name => 'longname9', value => 'x', mode => 2 }]}); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1487 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1488 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1489 ($frame) = grep { $_->{type} eq 'DATA' } @$frames; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1490 ok($frame, 'header size second'); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1491 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1492 $sess = new_session(8088); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1493 $sid = new_stream($sess, { headers => [ |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1494 { name => ':method', value => 'GET', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1495 { name => ':scheme', value => 'http', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1496 { name => ':path', value => '/t2.html', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1497 { name => ':authority', value => 'localhost', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1498 { name => 'longname9', value => 'xx', mode => 2 }]}); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1499 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1500 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1501 ($frame) = grep { $_->{type} eq 'DATA' } @$frames; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1502 ok($frame, 'header size equal'); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1503 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1504 $sess = new_session(8088); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1505 $sid = new_stream($sess, { headers => [ |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1506 { name => ':method', value => 'GET', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1507 { name => ':scheme', value => 'http', mode => 0 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1508 { name => ':path', value => '/t2.html', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1509 { name => ':authority', value => 'localhost', mode => 1 }, |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1510 { name => 'longname9', value => 'xxx', mode => 2 }]}); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1511 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1512 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1513 ($frame) = grep { $_->{type} eq 'DATA' } @$frames; |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1514 is($frame, undef, 'header size greater'); |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
1515 |
722
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1516 # header size is based on (decompressed) header list |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1517 # two extra 1-byte indices would otherwise fit in max_header_size |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1518 |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1519 $sess = new_session(8088); |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1520 $sid = new_stream($sess, { headers => [ |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1521 { name => ':method', value => 'GET', mode => 0 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1522 { name => ':scheme', value => 'http', mode => 0 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1523 { name => ':path', value => '/t2.html', mode => 1 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1524 { name => ':authority', value => 'localhost', mode => 1 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1525 { name => 'longname9', value => 'x', mode => 2 }]}); |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1526 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1527 |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1528 ($frame) = grep { $_->{type} eq 'DATA' } @$frames; |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1529 ok($frame, 'header size new index'); |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1530 |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1531 $sid = new_stream($sess, { headers => [ |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1532 { name => ':method', value => 'GET', mode => 0 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1533 { name => ':scheme', value => 'http', mode => 0 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1534 { name => ':path', value => '/t2.html', mode => 1 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1535 { name => ':authority', value => 'localhost', mode => 1 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1536 { name => 'longname9', value => 'x', mode => 0 }]}); |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1537 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1538 |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1539 ($frame) = grep { $_->{type} eq 'DATA' } @$frames; |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1540 ok($frame, 'header size indexed'); |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1541 |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1542 $sid = new_stream($sess, { headers => [ |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1543 { name => ':method', value => 'GET', mode => 0 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1544 { name => ':scheme', value => 'http', mode => 0 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1545 { name => ':path', value => '/t2.html', mode => 1 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1546 { name => ':authority', value => 'localhost', mode => 1 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1547 { name => 'longname9', value => 'x', mode => 0 }, |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1548 { name => 'longname9', value => 'x', mode => 0 }]}); |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1549 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1550 |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1551 ($frame) = grep { $_->{type} eq 'GOAWAY' } @$frames; |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1552 is($frame->{code}, 0xb, 'header size indexed greater'); |
e09a6cda6764
Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
721
diff
changeset
|
1553 |
736
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1554 # HPACK table boundary |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1555 |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1556 $sess = new_session(); |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1557 h2_read($sess, all => [{ sid => new_stream($sess, { headers => [ |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1558 { name => ':method', value => 'GET', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1559 { name => ':scheme', value => 'http', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1560 { name => ':path', value => '/', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1561 { name => ':authority', value => '', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1562 { name => 'x' x 2016, value => 'x' x 2048, mode => 2 }]}), fin => 1 }]); |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1563 $frames = h2_read($sess, all => [{ sid => new_stream($sess, { headers => [ |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1564 { name => ':method', value => 'GET', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1565 { name => ':scheme', value => 'http', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1566 { name => ':path', value => '/', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1567 { name => ':authority', value => '', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1568 { name => 'x' x 2016, value => 'x' x 2048, mode => 0 }]}), fin => 1 }]); |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1569 |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1570 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1571 ok($frame, 'HPACK table boundary'); |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1572 |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1573 h2_read($sess, all => [{ sid => new_stream($sess, { headers => [ |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1574 { name => ':method', value => 'GET', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1575 { name => ':scheme', value => 'http', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1576 { name => ':path', value => '/', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1577 { name => ':authority', value => '', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1578 { name => 'x' x 33, value => 'x' x 4031, mode => 2 }]}), fin => 1 }]); |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1579 $frames = h2_read($sess, all => [{ sid => new_stream($sess, { headers => [ |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1580 { name => ':method', value => 'GET', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1581 { name => ':scheme', value => 'http', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1582 { name => ':path', value => '/', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1583 { name => ':authority', value => '', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1584 { name => 'x' x 33, value => 'x' x 4031, mode => 0 }]}), fin => 1 }]); |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1585 |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1586 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1587 ok($frame, 'HPACK table boundary - header field name'); |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1588 |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1589 h2_read($sess, all => [{ sid => new_stream($sess, { headers => [ |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1590 { name => ':method', value => 'GET', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1591 { name => ':scheme', value => 'http', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1592 { name => ':path', value => '/', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1593 { name => ':authority', value => '', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1594 { name => 'x', value => 'x' x 64, mode => 2 }]}), fin => 1 }]); |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1595 $frames = h2_read($sess, all => [{ sid => new_stream($sess, { headers => [ |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1596 { name => ':method', value => 'GET', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1597 { name => ':scheme', value => 'http', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1598 { name => ':path', value => '/', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1599 { name => ':authority', value => '', mode => 0 }, |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1600 { name => 'x', value => 'x' x 64, mode => 0 }]}), fin => 1 }]); |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1601 |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1602 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1603 ok($frame, 'HPACK table boundary - header field value'); |
dcbe4c3d6871
Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
735
diff
changeset
|
1604 |
646 | 1605 # stream multiplexing + WINDOW_UPDATE |
1606 | |
1607 $sess = new_session(); | |
1608 $sid = new_stream($sess, { path => '/t1.html' }); | |
1609 $frames = h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1610 | |
1611 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1612 $sum = eval join '+', map { $_->{length} } @data; | |
1613 is($sum, 2**16 - 1, 'multiple - stream1 data'); | |
1614 | |
1615 my $sid2 = new_stream($sess, { path => '/t1.html' }); | |
1616 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1617 | |
1618 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1619 is(@data, 0, 'multiple - stream2 no data'); | |
1620 | |
1621 h2_window($sess, 2**17, $sid); | |
1622 h2_window($sess, 2**17, $sid2); | |
1623 h2_window($sess, 2**17); | |
1624 | |
1625 $frames = h2_read($sess, all => [ | |
1626 { sid => $sid, fin => 1 }, | |
1627 { sid => $sid2, fin => 1 } | |
1628 ]); | |
1629 | |
1630 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid } @$frames; | |
1631 $sum = eval join '+', map { $_->{length} } @data; | |
1632 is($sum, 81, 'multiple - stream1 remain data'); | |
1633 | |
1634 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid2 } @$frames; | |
1635 $sum = eval join '+', map { $_->{length} } @data; | |
1636 is($sum, 2**16 + 80, 'multiple - stream2 full data'); | |
1637 | |
1638 # stream muliplexing + PRIORITY frames | |
1639 | |
1640 $sess = new_session(); | |
1641 $sid = new_stream($sess, { path => '/t1.html' }); | |
1642 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1643 | |
1644 $sid2 = new_stream($sess, { path => '/t2.html' }); | |
1645 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1646 | |
1647 h2_priority($sess, 0, $sid); | |
1648 h2_priority($sess, 255, $sid2); | |
1649 | |
1650 h2_window($sess, 2**17, $sid); | |
1651 h2_window($sess, 2**17, $sid2); | |
1652 h2_window($sess, 2**17); | |
1653 | |
1654 $frames = h2_read($sess, all => [ | |
1655 { sid => $sid, fin => 1 }, | |
1656 { sid => $sid2, fin => 1 } | |
1657 ]); | |
1658 | |
1659 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1660 is(join(' ', map { $_->{sid} } @data), "$sid2 $sid", 'weight - PRIORITY 1'); | |
1661 | |
1662 # and vice versa | |
1663 | |
1664 $sess = new_session(); | |
1665 $sid = new_stream($sess, { path => '/t1.html' }); | |
1666 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1667 | |
1668 $sid2 = new_stream($sess, { path => '/t2.html' }); | |
1669 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1670 | |
1671 h2_priority($sess, 255, $sid); | |
1672 h2_priority($sess, 0, $sid2); | |
1673 | |
1674 h2_window($sess, 2**17, $sid); | |
1675 h2_window($sess, 2**17, $sid2); | |
1676 h2_window($sess, 2**17); | |
1677 | |
1678 $frames = h2_read($sess, all => [ | |
1679 { sid => $sid, fin => 1 }, | |
1680 { sid => $sid2, fin => 1 } | |
1681 ]); | |
1682 | |
1683 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1684 is(join(' ', map { $_->{sid} } @data), "$sid $sid2", 'weight - PRIORITY 2'); | |
1685 | |
1686 # stream muliplexing + HEADERS PRIORITY flag | |
1687 | |
1688 $sess = new_session(); | |
1689 $sid = new_stream($sess, { path => '/t1.html', prio => 0 }); | |
1690 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1691 | |
1692 $sid2 = new_stream($sess, { path => '/t2.html', prio => 255 }); | |
1693 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1694 | |
1695 h2_window($sess, 2**17, $sid); | |
1696 h2_window($sess, 2**17, $sid2); | |
1697 h2_window($sess, 2**17); | |
1698 | |
1699 $frames = h2_read($sess, all => [ | |
1700 { sid => $sid, fin => 1 }, | |
1701 { sid => $sid2, fin => 1 } | |
1702 ]); | |
1703 | |
1704 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1705 my $sids = join ' ', map { $_->{sid} } @data; | |
1706 is($sids, "$sid2 $sid", 'weight - HEADERS PRIORITY 1'); | |
1707 | |
1708 # and vice versa | |
1709 | |
1710 $sess = new_session(); | |
1711 $sid = new_stream($sess, { path => '/t1.html', prio => 255 }); | |
1712 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1713 | |
1714 $sid2 = new_stream($sess, { path => '/t2.html', prio => 0 }); | |
1715 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1716 | |
1717 h2_window($sess, 2**17, $sid); | |
1718 h2_window($sess, 2**17, $sid2); | |
1719 h2_window($sess, 2**17); | |
1720 | |
1721 $frames = h2_read($sess, all => [ | |
1722 { sid => $sid, fin => 1 }, | |
1723 { sid => $sid2, fin => 1 } | |
1724 ]); | |
1725 | |
1726 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1727 $sids = join ' ', map { $_->{sid} } @data; | |
1728 is($sids, "$sid $sid2", 'weight - HEADERS PRIORITY 2'); | |
1729 | |
1730 # 5.3.1. Stream Dependencies | |
1731 | |
1732 # PRIORITY frame | |
1733 | |
1734 $sess = new_session(); | |
1735 | |
1736 h2_priority($sess, 16, 3, 0); | |
1737 h2_priority($sess, 16, 1, 3); | |
1738 | |
1739 $sid = new_stream($sess, { path => '/t1.html' }); | |
1740 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1741 | |
1742 $sid2 = new_stream($sess, { path => '/t2.html' }); | |
1743 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1744 | |
1745 h2_window($sess, 2**17, $sid); | |
1746 h2_window($sess, 2**17, $sid2); | |
1747 h2_window($sess, 2**17); | |
1748 | |
1749 $frames = h2_read($sess, all => [ | |
1750 { sid => $sid, fin => 1 }, | |
1751 { sid => $sid2, fin => 1 }, | |
1752 ]); | |
1753 | |
1754 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1755 $sids = join ' ', map { $_->{sid} } @data; | |
1756 is($sids, "$sid2 $sid", 'dependency - PRIORITY 1'); | |
1757 | |
1758 # and vice versa | |
1759 | |
1760 $sess = new_session(); | |
1761 | |
1762 h2_priority($sess, 16, 1, 0); | |
1763 h2_priority($sess, 16, 3, 1); | |
1764 | |
1765 $sid = new_stream($sess, { path => '/t1.html' }); | |
1766 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1767 | |
1768 $sid2 = new_stream($sess, { path => '/t2.html' }); | |
1769 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1770 | |
1771 h2_window($sess, 2**17, $sid); | |
1772 h2_window($sess, 2**17, $sid2); | |
1773 h2_window($sess, 2**17); | |
1774 | |
1775 $frames = h2_read($sess, all => [ | |
1776 { sid => $sid, fin => 1 }, | |
1777 { sid => $sid2, fin => 1 }, | |
1778 ]); | |
1779 | |
1780 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1781 $sids = join ' ', map { $_->{sid} } @data; | |
1782 is($sids, "$sid $sid2", 'dependency - PRIORITY 2'); | |
1783 | |
1784 # HEADERS PRIORITY flag, reprioritize prior PRIORITY frame records | |
1785 | |
1786 $sess = new_session(); | |
1787 | |
1788 h2_priority($sess, 16, 1, 0); | |
1789 h2_priority($sess, 16, 3, 0); | |
1790 | |
1791 $sid = new_stream($sess, { path => '/t1.html', dep => 3 }); | |
1792 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1793 | |
1794 $sid2 = new_stream($sess, { path => '/t2.html' }); | |
1795 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1796 | |
1797 h2_window($sess, 2**17, $sid); | |
1798 h2_window($sess, 2**17, $sid2); | |
1799 h2_window($sess, 2**17); | |
1800 | |
1801 $frames = h2_read($sess, all => [ | |
1802 { sid => $sid, fin => 1 }, | |
1803 { sid => $sid2, fin => 1 }, | |
1804 ]); | |
1805 | |
1806 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1807 $sids = join ' ', map { $_->{sid} } @data; | |
1808 is($sids, "$sid2 $sid", 'dependency - HEADERS PRIORITY 1'); | |
1809 | |
1810 # and vice versa | |
1811 | |
1812 $sess = new_session(); | |
1813 | |
1814 h2_priority($sess, 16, 1, 0); | |
1815 h2_priority($sess, 16, 3, 0); | |
1816 | |
1817 $sid = new_stream($sess, { path => '/t1.html' }); | |
1818 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1819 | |
1820 $sid2 = new_stream($sess, { path => '/t2.html', dep => 1 }); | |
1821 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1822 | |
1823 h2_window($sess, 2**17, $sid); | |
1824 h2_window($sess, 2**17, $sid2); | |
1825 h2_window($sess, 2**17); | |
1826 | |
1827 $frames = h2_read($sess, all => [ | |
1828 { sid => $sid, fin => 1 }, | |
1829 { sid => $sid2, fin => 1 }, | |
1830 ]); | |
1831 | |
1832 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1833 $sids = join ' ', map { $_->{sid} } @data; | |
1834 is($sids, "$sid $sid2", 'dependency - HEADERS PRIORITY 2'); | |
1835 | |
662
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1836 # PRIORITY frame, weighted dependencies |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1837 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1838 $sess = new_session(); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1839 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1840 h2_priority($sess, 16, 5, 0); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1841 h2_priority($sess, 255, 1, 5); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1842 h2_priority($sess, 0, 3, 5); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1843 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1844 $sid = new_stream($sess, { path => '/t1.html' }); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1845 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1846 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1847 $sid2 = new_stream($sess, { path => '/t2.html' }); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1848 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1849 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1850 my $sid3 = new_stream($sess, { path => '/t2.html' }); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1851 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1852 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1853 h2_window($sess, 2**16, 1); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1854 h2_window($sess, 2**16, 3); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1855 h2_window($sess, 2**16, 5); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1856 h2_window($sess, 2**16); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1857 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1858 $frames = h2_read($sess, all => [ |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1859 { sid => $sid, fin => 1 }, |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1860 { sid => $sid2, fin => 1 }, |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1861 { sid => $sid3, fin => 1 }, |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1862 ]); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1863 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1864 @data = grep { $_->{type} eq "DATA" } @$frames; |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1865 $sids = join ' ', map { $_->{sid} } @data; |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1866 is($sids, "$sid3 $sid $sid2", 'weighted dependency - PRIORITY 1'); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1867 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1868 # and vice versa |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1869 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1870 $sess = new_session(); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1871 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1872 h2_priority($sess, 16, 5, 0); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1873 h2_priority($sess, 0, 1, 5); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1874 h2_priority($sess, 255, 3, 5); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1875 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1876 $sid = new_stream($sess, { path => '/t1.html' }); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1877 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1878 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1879 $sid2 = new_stream($sess, { path => '/t2.html' }); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1880 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1881 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1882 $sid3 = new_stream($sess, { path => '/t2.html' }); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1883 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1884 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1885 h2_window($sess, 2**16, 1); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1886 h2_window($sess, 2**16, 3); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1887 h2_window($sess, 2**16, 5); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1888 h2_window($sess, 2**16); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1889 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1890 $frames = h2_read($sess, all => [ |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1891 { sid => $sid, fin => 1 }, |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1892 { sid => $sid2, fin => 1 }, |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1893 { sid => $sid3, fin => 1 }, |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1894 ]); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1895 |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1896 @data = grep { $_->{type} eq "DATA" } @$frames; |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1897 $sids = join ' ', map { $_->{sid} } @data; |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1898 is($sids, "$sid3 $sid2 $sid", 'weighted dependency - PRIORITY 2'); |
07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents:
661
diff
changeset
|
1899 |
646 | 1900 # limit_conn |
1901 | |
1902 $sess = new_session(); | |
1903 h2_settings($sess, 0, 0x4 => 1); | |
1904 | |
1905 $sid = new_stream($sess, { path => '/t3.html' }); | |
1906 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]); | |
1907 | |
1908 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames; | |
1909 is($frame->{headers}->{':status'}, 200, 'limit_conn first stream'); | |
1910 | |
1911 $sid2 = new_stream($sess, { path => '/t3.html' }); | |
1912 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0 }]); | |
1913 | |
1914 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames; | |
1915 is($frame->{headers}->{':status'}, 503, 'limit_conn rejected'); | |
1916 | |
1917 h2_settings($sess, 0, 0x4 => 2**16); | |
1918 | |
1919 h2_read($sess, all => [ | |
1920 { sid => $sid, fin => 1 }, | |
1921 { sid => $sid2, fin => 1 } | |
1922 ]); | |
1923 | |
1924 # limit_conn + client's RST_STREAM | |
1925 | |
1926 $sess = new_session(); | |
1927 h2_settings($sess, 0, 0x4 => 1); | |
1928 | |
1929 $sid = new_stream($sess, { path => '/t3.html' }); | |
1930 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]); | |
1931 h2_rst($sess, $sid, 5); | |
1932 | |
1933 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames; | |
1934 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 1'); | |
1935 | |
1936 $sid2 = new_stream($sess, { path => '/t3.html' }); | |
1937 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0 }]); | |
1938 | |
1939 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames; | |
1940 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 2'); | |
1941 | |
654
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1942 # http2_max_concurrent_streams |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1943 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1944 $sess = new_session(8086); |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1945 $frames = h2_read($sess, all => [{ type => 'SETTINGS' }]); |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1946 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1947 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames; |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1948 is($frame->{3}, 1, 'http2_max_concurrent_streams SETTINGS'); |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1949 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1950 h2_window($sess, 2**18); |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1951 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1952 $sid = new_stream($sess, { path => '/t1.html' }); |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1953 $frames = h2_read($sess, all => [{ sid => $sid, length => 2 ** 16 - 1 }]); |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1954 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1955 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames; |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1956 is($frame->{headers}->{':status'}, 200, 'http2_max_concurrent_streams'); |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1957 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1958 $sid2 = new_stream($sess, { path => '/t1.html' }); |
667
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
1959 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]); |
654
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1960 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1961 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames; |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1962 isnt($frame->{headers}->{':status'}, 200, 'http2_max_concurrent_streams 2'); |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
1963 |
667
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
1964 ($frame) = grep { $_->{type} eq "RST_STREAM" && $_->{sid} == $sid2 } @$frames; |
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
1965 is($frame->{sid}, $sid2, 'http2_max_concurrent_streams RST_STREAM sid'); |
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
1966 is($frame->{length}, 4, 'http2_max_concurrent_streams RST_STREAM length'); |
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
1967 is($frame->{flags}, 0, 'http2_max_concurrent_streams RST_STREAM flags'); |
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
1968 is($frame->{code}, 7, 'http2_max_concurrent_streams RST_STREAM code'); |
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
1969 |
715
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1970 # properly skip header field that's not/never indexed from discarded streams |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1971 |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1972 $sid2 = new_stream($sess, { headers => [ |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1973 { name => ':method', value => 'GET' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1974 { name => ':scheme', value => 'http' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1975 { name => ':path', value => '/', mode => 6 }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1976 { name => ':authority', value => 'localhost' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1977 { name => 'x-foo', value => 'Foo', mode => 2 }]}); |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1978 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]); |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1979 |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1980 # also if split across writes |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1981 |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1982 $sid2 = new_stream($sess, { split => [ 22 ], headers => [ |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1983 { name => ':method', value => 'GET' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1984 { name => ':scheme', value => 'http' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1985 { name => ':path', value => '/', mode => 6 }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1986 { name => ':authority', value => 'localhost' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1987 { name => 'x-bar', value => 'Bar', mode => 2 }]}); |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1988 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]); |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1989 |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1990 # also if split across frames |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1991 |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1992 $sid2 = new_stream($sess, { continuation => [ 17 ], headers => [ |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1993 { name => ':method', value => 'GET' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1994 { name => ':scheme', value => 'http' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1995 { name => ':path', value => '/', mode => 6 }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1996 { name => ':authority', value => 'localhost' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1997 { name => 'x-baz', value => 'Baz', mode => 2 }]}); |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1998 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]); |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1999 |
661
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
2000 h2_window($sess, 2**16, $sid); |
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
2001 h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
2002 |
715
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2003 $sid = new_stream($sess, { headers => [ |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2004 { name => ':method', value => 'GET' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2005 { name => ':scheme', value => 'http' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2006 { name => ':path', value => '/t2.html' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2007 { name => ':authority', value => 'localhost' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2008 # make sure that discarded streams updated dynamic table |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2009 { name => 'x-foo', value => 'Foo', mode => 0 }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2010 { name => 'x-bar', value => 'Bar', mode => 0 }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2011 { name => 'x-baz', value => 'Baz', mode => 0 }]}); |
661
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
2012 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
2013 |
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
2014 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames; |
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
2015 is($frame->{headers}->{':status'}, 200, 'http2_max_concurrent_streams 3'); |
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
2016 |
646 | 2017 |
2018 # some invalid cases below | |
2019 | |
728
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2020 # invalid connection preface |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2021 |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2022 $sess = new_session(8080, preface => 'bogus preface'); |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2023 $sid = new_stream($sess, { path => '/pp' }); |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2024 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2025 |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2026 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2027 ok($frame, 'invalid preface - GOAWAY frame'); |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2028 is($frame->{code}, 1, 'invalid preface - error code'); |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2029 |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2030 $sess = new_session(8080, preface => 'PRI * HTTP/2.0' . CRLF . CRLF . 'bogus'); |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2031 $sid = new_stream($sess, { path => '/pp' }); |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2032 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2033 |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2034 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2035 ok($frame, 'invalid preface 2 - GOAWAY frame'); |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2036 is($frame->{code}, 1, 'invalid preface 2 - error code'); |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2037 |
727
3e034902ebe7
Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
724
diff
changeset
|
2038 # invalid PROXY protocol string |
3e034902ebe7
Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
724
diff
changeset
|
2039 |
3e034902ebe7
Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
724
diff
changeset
|
2040 $sess = new_session(8082, proxy => 'bogus'); |
3e034902ebe7
Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
724
diff
changeset
|
2041 $sid = new_stream($sess, { path => '/pp' }); |
3e034902ebe7
Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
724
diff
changeset
|
2042 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
3e034902ebe7
Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
724
diff
changeset
|
2043 |
3e034902ebe7
Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
724
diff
changeset
|
2044 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
3e034902ebe7
Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
724
diff
changeset
|
2045 ok($frame, 'invalid PROXY - GOAWAY frame'); |
3e034902ebe7
Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
724
diff
changeset
|
2046 is($frame->{code}, 1, 'invalid PROXY - error code'); |
3e034902ebe7
Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
724
diff
changeset
|
2047 |
675
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2048 # ensure that request header field value with newline doesn't get split |
677
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2049 # |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2050 # 10.3. Intermediary Encapsulation Attacks |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2051 # Any request or response that contains a character not permitted |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2052 # in a header field value MUST be treated as malformed. |
675
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2053 |
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2054 $sess = new_session(); |
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2055 $sid = new_stream($sess, { headers => [ |
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2056 { name => ':method', value => 'GET', mode => 0 }, |
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2057 { name => ':scheme', value => 'http', mode => 0 }, |
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2058 { name => ':path', value => '/proxy2/', mode => 1 }, |
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2059 { name => ':authority', value => 'localhost', mode => 1 }, |
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2060 { name => 'x-foo', value => "x-bar\r\nreferer:see-this", mode => 2 }]}); |
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2061 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2062 |
677
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2063 # 10.3. Intermediary Encapsulation Attacks |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2064 # An intermediary therefore cannot translate an HTTP/2 request or response |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2065 # containing an invalid field name into an HTTP/1.1 message. |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2066 |
675
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2067 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2068 isnt($frame->{headers}->{'x-referer'}, 'see-this', 'newline in request header'); |
42de9efd11ee
Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents:
673
diff
changeset
|
2069 |
677
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2070 # 8.1.2.6. Malformed Requests and Responses |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2071 # Malformed requests or responses that are detected MUST be treated |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2072 # as a stream error (Section 5.4.2) of type PROTOCOL_ERROR. |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2073 |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2074 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2075 is($frame->{sid}, $sid, 'newline in request header - RST_STREAM sid'); |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2076 is($frame->{length}, 4, 'newline in request header - RST_STREAM length'); |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2077 is($frame->{flags}, 0, 'newline in request header - RST_STREAM flags'); |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2078 is($frame->{code}, 1, 'newline in request header - RST_STREAM code'); |
5d258aa5ebc5
Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
675
diff
changeset
|
2079 |
646 | 2080 # GOAWAY on SYN_STREAM with even StreamID |
2081 | |
2082 $sess = new_session(); | |
2083 new_stream($sess, { path => '/' }, 2); | |
2084 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]); | |
2085 | |
2086 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
2087 ok($frame, 'even stream - GOAWAY frame'); | |
2088 is($frame->{code}, 1, 'even stream - error code'); | |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2089 is($frame->{last_sid}, 0, 'even stream - last stream'); |
646 | 2090 |
2091 # GOAWAY on SYN_STREAM with backward StreamID | |
2092 | |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2093 # 5.1.1. Stream Identifiers |
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2094 # The first use of a new stream identifier implicitly closes all |
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2095 # streams in the "idle" state <..> with a lower-valued stream identifier. |
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2096 |
646 | 2097 $sess = new_session(); |
2098 $sid = new_stream($sess, { path => '/' }, 3); | |
2099 h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
2100 | |
2101 $sid2 = new_stream($sess, { path => '/' }, 1); | |
2102 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]); | |
2103 | |
2104 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
2105 ok($frame, 'backward stream - GOAWAY frame'); | |
2106 is($frame->{code}, 1, 'backward stream - error code'); | |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2107 is($frame->{last_sid}, $sid, 'backward stream - last stream'); |
646 | 2108 |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2109 # GOAWAY on the second SYN_STREAM with same StreamID |
646 | 2110 |
2111 $sess = new_session(); | |
2112 $sid = new_stream($sess, { path => '/' }); | |
2113 h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
2114 | |
2115 $sid2 = new_stream($sess, { path => '/' }, $sid); | |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2116 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]); |
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2117 |
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2118 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2119 ok($frame, 'dup stream - GOAWAY frame'); |
646 | 2120 is($frame->{code}, 1, 'dup stream - error code'); |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
2121 is($frame->{last_sid}, $sid, 'dup stream - last stream'); |
646 | 2122 |
2123 # missing mandatory request header ':scheme' | |
2124 | |
2125 TODO: { | |
2126 local $TODO = 'not yet'; | |
2127 | |
2128 $sess = new_session(); | |
2129 $sid = new_stream($sess, { headers => [ | |
2130 { name => ':method', value => 'GET', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
2131 { name => ':path', value => '/', mode => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
2132 { name => ':authority', value => 'localhost', mode => 1 }]}); |
646 | 2133 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
2134 | |
2135 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
2136 is($frame->{headers}->{':status'}, 400, 'incomplete headers'); | |
2137 | |
2138 } | |
2139 | |
673
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2140 # empty request header ':authority' |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2141 |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2142 $sess = new_session(); |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2143 $sid = new_stream($sess, { headers => [ |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2144 { name => ':method', value => 'GET', mode => 0 }, |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2145 { name => ':scheme', value => 'http', mode => 0 }, |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2146 { name => ':path', value => '/', mode => 0 }, |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2147 { name => ':authority', value => '', mode => 0 }]}); |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2148 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2149 |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2150 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2151 is($frame->{headers}->{':status'}, 400, 'empty authority'); |
9d6c865c2869
Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents:
672
diff
changeset
|
2152 |
697
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2153 # unknown frame type |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2154 |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2155 $sess = new_session(); |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2156 h2_unknown($sess, 'payload'); |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2157 h2_ping($sess, 'SEE-THIS'); |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2158 $frames = h2_read($sess, all => [{ type => 'PING' }]); |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2159 |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2160 ($frame) = grep { $_->{type} eq "PING" } @$frames; |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2161 is($frame->{value}, 'SEE-THIS', 'unknown frame type'); |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2162 |
646 | 2163 # GOAWAY - force closing a connection by server |
2164 | |
2165 $sid = new_stream($sess, { path => 't1.html' }); | |
2166 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
2167 | |
2168 $t->stop(); | |
2169 | |
2170 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]); | |
2171 | |
2172 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
2173 ok($frame, 'GOAWAY on connection close'); | |
2174 | |
2175 ############################################################################### | |
2176 | |
2177 sub h2_ping { | |
2178 my ($sess, $payload) = @_; | |
2179 | |
2180 raw_write($sess->{socket}, pack("x2C2x5a8", 8, 0x6, $payload)); | |
2181 } | |
2182 | |
2183 sub h2_rst { | |
2184 my ($sess, $stream, $error) = @_; | |
2185 | |
2186 raw_write($sess->{socket}, pack("x2C2xNN", 4, 0x3, $stream, $error)); | |
2187 } | |
2188 | |
2189 sub h2_priority { | |
2190 my ($sess, $w, $stream, $dep) = @_; | |
2191 | |
2192 $stream = 0 unless defined $stream; | |
2193 $dep = 0 unless defined $dep; | |
2194 raw_write($sess->{socket}, pack("x2C2xNNC", 5, 0x2, $stream, $dep, $w)); | |
2195 } | |
2196 | |
2197 sub h2_window { | |
2198 my ($sess, $win, $stream) = @_; | |
2199 | |
2200 $stream = 0 unless defined $stream; | |
2201 raw_write($sess->{socket}, pack("x2C2xNN", 4, 0x8, $stream, $win)); | |
2202 } | |
2203 | |
2204 sub h2_settings { | |
2205 my ($sess, $ack, %extra) = @_; | |
2206 | |
2207 my $len = 6 * keys %extra; | |
2208 my $buf = pack_length($len) . pack "CCx4", 0x4, $ack ? 0x1 : 0x0; | |
2209 $buf .= join '', map { pack "nN", $_, $extra{$_} } keys %extra; | |
2210 raw_write($sess->{socket}, $buf); | |
2211 } | |
2212 | |
697
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2213 sub h2_unknown { |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2214 my ($sess, $payload) = @_; |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2215 |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2216 my $buf = pack_length(length($payload)) . pack("Cx5a*", 0xa, $payload); |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2217 raw_write($sess->{socket}, $buf); |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2218 } |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
2219 |
646 | 2220 sub h2_continue { |
2221 my ($ctx, $stream, $uri) = @_; | |
2222 | |
2223 $uri->{h2_continue} = 1; | |
2224 return new_stream($ctx, $uri, $stream); | |
2225 } | |
2226 | |
2227 sub new_stream { | |
2228 my ($ctx, $uri, $stream) = @_; | |
2229 my ($input, $buf); | |
2230 my ($d, $status); | |
2231 | |
718
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
2232 $ctx->{headers} = ''; |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
2233 |
646 | 2234 my $host = $uri->{host} || '127.0.0.1:8080'; |
2235 my $method = $uri->{method} || 'GET'; | |
2236 my $scheme = $uri->{scheme} || 'http'; | |
2237 my $path = $uri->{path} || '/'; | |
2238 my $headers = $uri->{headers}; | |
2239 my $body = $uri->{body}; | |
2240 my $prio = $uri->{prio}; | |
2241 my $dep = $uri->{dep}; | |
699
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2242 my $split = ref $uri->{continuation} && $uri->{continuation} || []; |
646 | 2243 |
2244 my $pad = defined $uri->{padding} ? $uri->{padding} : 0; | |
2245 my $padlen = defined $uri->{padding} ? 1 : 0; | |
2246 my $bpad = defined $uri->{body_padding} ? $uri->{body_padding} : 0; | |
2247 my $bpadlen = defined $uri->{body_padding} ? 1 : 0; | |
2248 | |
2249 my $type = defined $uri->{h2_continue} ? 0x9 : 0x1; | |
2250 my $flags = defined $uri->{continuation} ? 0x0 : 0x4; | |
2251 $flags |= 0x1 unless defined $body; | |
2252 $flags |= 0x8 if $padlen; | |
2253 $flags |= 0x20 if defined $dep || defined $prio; | |
2254 | |
2255 if ($stream) { | |
2256 $ctx->{last_stream} = $stream; | |
2257 } else { | |
2258 $ctx->{last_stream} += 2; | |
2259 } | |
2260 | |
2261 $buf = pack("xxx"); # Length stub | |
2262 $buf .= pack("CC", $type, $flags); # END_HEADERS | |
2263 $buf .= pack("N", $ctx->{last_stream}); # Stream-ID | |
2264 | |
2265 $dep = 0 if defined $prio and not defined $dep; | |
2266 $prio = 16 if defined $dep and not defined $prio; | |
2267 | |
2268 unless ($headers) { | |
2269 $input = hpack($ctx, ":method", $method); | |
2270 $input .= hpack($ctx, ":scheme", $scheme); | |
2271 $input .= hpack($ctx, ":path", $path); | |
2272 $input .= hpack($ctx, ":authority", $host); | |
2273 $input .= hpack($ctx, "content-length", length($body)) if $body; | |
2274 | |
2275 } else { | |
2276 $input = join '', map { | |
2277 hpack($ctx, $_->{name}, $_->{value}, | |
2278 mode => $_->{mode}, huff => $_->{huff}) | |
2279 } @$headers if $headers; | |
2280 } | |
2281 | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2282 $input = pack("B*", '001' . ipack(5, $uri->{table_size})) . $input |
646 | 2283 if defined $uri->{table_size}; |
2284 | |
702
cc2b98d028c8
Tests: fixed HTTP/2 test for CONTINUATION while in header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
700
diff
changeset
|
2285 my @input = map { substr $input, 0, $_, "" } @$split; |
699
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2286 push @input, $input; |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2287 |
646 | 2288 # set length, attach headers, padding, priority |
2289 | |
699
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2290 my $hlen = length($input[0]) + $pad + $padlen; |
646 | 2291 $hlen += 5 if $flags & 0x20; |
2292 $buf |= pack_length($hlen); | |
2293 | |
2294 $buf .= pack 'C', $pad if $padlen; # Pad Length? | |
2295 $buf .= pack 'NC', $dep, $prio if $flags & 0x20; | |
699
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2296 $buf .= $input[0]; |
646 | 2297 $buf .= (pack 'C', 0) x $pad if $padlen; # Padding |
2298 | |
699
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2299 shift @input; |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2300 |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2301 while (@input) { |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2302 $input = shift @input; |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2303 $flags = @input ? 0x0 : 0x4; |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2304 $buf .= pack_length(length($input)); |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2305 $buf .= pack("CC", 0x9, $flags); |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2306 $buf .= pack("N", $ctx->{last_stream}); |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2307 $buf .= $input; |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2308 } |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
2309 |
646 | 2310 if (defined $body) { |
2311 $buf .= pack_length(length($body) + $bpad + $bpadlen); | |
2312 my $flags = $bpadlen ? 0x8 : 0x0; | |
2313 $buf .= pack 'CC', 0x0, 0x1 | $flags; # DATA, END_STREAM | |
2314 $buf .= pack 'N', $ctx->{last_stream}; | |
2315 $buf .= pack 'C', $bpad if $bpadlen; # DATA Pad Length? | |
2316 $buf .= $body; | |
2317 $buf .= (pack 'C', 0) x $bpad if $bpadlen; # DATA Padding | |
2318 } | |
2319 | |
715
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2320 $split = ref $uri->{split} && $uri->{split} || []; |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2321 for (@$split) { |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2322 raw_write($ctx->{socket}, substr($buf, 0, $_, "")); |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2323 select undef, undef, undef, 0.2; |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2324 } |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
2325 |
646 | 2326 raw_write($ctx->{socket}, $buf); |
2327 return $ctx->{last_stream}; | |
2328 } | |
2329 | |
2330 sub h2_read { | |
2331 my ($sess, %extra) = @_; | |
2332 my (@got); | |
2333 my $s = $sess->{socket}; | |
2334 my $buf = ''; | |
2335 | |
2336 while (1) { | |
2337 $buf = raw_read($s, $buf, 9); | |
2338 last unless length $buf; | |
2339 | |
2340 my $length = unpack_length($buf); | |
2341 my $type = unpack('x3C', $buf); | |
2342 my $flags = unpack('x4C', $buf); | |
2343 | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2344 my $stream = unpack "x5 B32", $buf; |
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2345 substr($stream, 0, 1) = 0; |
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2346 $stream = unpack("N", pack("B32", $stream)); |
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2347 |
679
b60c1a207675
Tests: fixed HTTP/2 tests with large frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
677
diff
changeset
|
2348 $buf = raw_read($s, $buf, $length + 9); |
724
4322541b80ed
Tests: avoid uninitialized warnings in h2.t with partial frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
723
diff
changeset
|
2349 last if length($buf) < $length + 9; |
646 | 2350 |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2351 $buf = substr($buf, 9); |
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2352 |
718
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
2353 my $frame = $cframe{$type}{value}($sess, $buf, $length, $flags); |
646 | 2354 $frame->{length} = $length; |
2355 $frame->{type} = $cframe{$type}{name}; | |
2356 $frame->{flags} = $flags; | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2357 $frame->{sid} = $stream; |
646 | 2358 push @got, $frame; |
2359 | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2360 $buf = substr($buf, $length); |
646 | 2361 |
2362 last unless test_fin($got[-1], $extra{all}); | |
2363 }; | |
2364 return \@got; | |
2365 } | |
2366 | |
2367 sub test_fin { | |
2368 my ($frame, $all) = @_; | |
2369 my @test = @{$all}; | |
2370 | |
2371 # wait for the specified DATA length | |
2372 | |
2373 for (@test) { | |
2374 if ($_->{length} && $frame->{type} eq 'DATA') { | |
2375 # check also for StreamID if needed | |
2376 | |
2377 if (!$_->{sid} || $_->{sid} == $frame->{sid}) { | |
2378 $_->{length} -= $frame->{length}; | |
2379 } | |
2380 } | |
2381 } | |
2382 @test = grep { !(defined $_->{length} && $_->{length} == 0) } @test; | |
2383 | |
2384 # wait for the fin flag | |
2385 | |
2386 @test = grep { !(defined $_->{fin} | |
2387 && $_->{sid} == $frame->{sid} && $_->{fin} & $frame->{flags}) | |
2388 } @test if defined $frame->{flags}; | |
2389 | |
2390 # wait for the specified frame | |
2391 | |
2392 @test = grep { !($_->{type} && $_->{type} eq $frame->{type}) } @test; | |
2393 | |
2394 @{$all} = @test; | |
2395 } | |
2396 | |
2397 sub headers { | |
718
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
2398 my ($ctx, $buf, $len, $flags) = @_; |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
2399 $ctx->{headers} .= substr($buf, 0, $len); |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
2400 return unless $flags & 0x4; |
ba822b2e899c
Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
717
diff
changeset
|
2401 { headers => hunpack($ctx, $ctx->{headers}, length($ctx->{headers})) }; |
646 | 2402 } |
2403 | |
2404 sub data { | |
2405 my ($ctx, $buf, $len) = @_; | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2406 return { data => substr($buf, 0, $len) }; |
646 | 2407 } |
2408 | |
2409 sub settings { | |
2410 my ($ctx, $buf, $len) = @_; | |
2411 my %payload; | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2412 my $skip = 0; |
646 | 2413 |
2414 for (1 .. $len / 6) { | |
2415 my $id = hex unpack "\@$skip n", $buf; $skip += 2; | |
2416 $payload{$id} = unpack "\@$skip N", $buf; $skip += 4; | |
2417 } | |
2418 return \%payload; | |
2419 } | |
2420 | |
2421 sub ping { | |
2422 my ($ctx, $buf, $len) = @_; | |
670
944b87756cab
Tests: fixed GOAWAY and PING frames parsing in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
669
diff
changeset
|
2423 return { value => unpack "A$len", $buf }; |
646 | 2424 } |
2425 | |
2426 sub rst_stream { | |
2427 my ($ctx, $buf, $len) = @_; | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2428 return { code => unpack "N", $buf }; |
646 | 2429 } |
2430 | |
2431 sub goaway { | |
2432 my ($ctx, $buf, $len) = @_; | |
2433 my %payload; | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2434 |
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2435 my $stream = unpack "B32", $buf; |
646 | 2436 substr($stream, 0, 1) = 0; |
2437 $stream = unpack("N", pack("B32", $stream)); | |
2438 $payload{last_sid} = $stream; | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2439 |
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2440 $len -= 4; |
670
944b87756cab
Tests: fixed GOAWAY and PING frames parsing in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
669
diff
changeset
|
2441 $payload{code} = unpack "x4 N", $buf; |
944b87756cab
Tests: fixed GOAWAY and PING frames parsing in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
669
diff
changeset
|
2442 $payload{debug} = unpack "x8 A$len", $buf; |
646 | 2443 return \%payload; |
2444 } | |
2445 | |
2446 sub window_update { | |
2447 my ($ctx, $buf, $len) = @_; | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2448 my $value = unpack "B32", $buf; |
646 | 2449 substr($value, 0, 1) = 0; |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
2450 return { wdelta => unpack("N", pack("B32", $value)) }; |
646 | 2451 } |
2452 | |
2453 sub pack_length { | |
2454 pack 'c3', unpack 'xc3', pack 'N', $_[0]; | |
2455 } | |
2456 | |
2457 sub unpack_length { | |
2458 unpack 'N', pack 'xc3', unpack 'c3', $_[0]; | |
2459 } | |
2460 | |
2461 sub raw_read { | |
2462 my ($s, $buf, $len) = @_; | |
2463 my $got = ''; | |
2464 | |
2465 while (length($buf) < $len && IO::Select->new($s)->can_read(1)) { | |
650
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
2466 $s->sysread($got, 16384) or last; |
646 | 2467 log_in($got); |
2468 $buf .= $got; | |
2469 } | |
2470 return $buf; | |
2471 } | |
2472 | |
2473 sub raw_write { | |
2474 my ($s, $message) = @_; | |
2475 | |
2476 local $SIG{PIPE} = 'IGNORE'; | |
2477 | |
2478 while (IO::Select->new($s)->can_write(0.4)) { | |
2479 log_out($message); | |
2480 my $n = $s->syswrite($message); | |
2481 last unless $n; | |
2482 $message = substr($message, $n); | |
2483 last unless length $message; | |
2484 } | |
2485 } | |
2486 | |
2487 sub new_session { | |
2488 my ($port, %extra) = @_; | |
728
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2489 |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2490 my $s = new_socket($port, %extra); |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2491 my $preface = $extra{preface} |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2492 || 'PRI * HTTP/2.0' . CRLF . CRLF . 'SM' . CRLF . CRLF; |
646 | 2493 |
2494 if ($extra{proxy}) { | |
2495 raw_write($s, $extra{proxy}); | |
2496 } | |
2497 | |
2498 # preface | |
2499 | |
728
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
2500 raw_write($s, $preface); |
646 | 2501 |
2502 return { socket => $s, last_stream => -1, | |
2503 dynamic_encode => [ static_table() ], | |
2504 dynamic_decode => [ static_table() ], | |
2505 static_table_size => scalar @{[static_table()]} }; | |
2506 } | |
2507 | |
2508 sub new_socket { | |
650
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
2509 my ($port, %extra) = @_; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
2510 my $npn = $extra{'npn'}; |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
2511 my $alpn = $extra{'alpn'}; |
646 | 2512 my $s; |
2513 | |
2514 $port = 8080 unless defined $port; | |
2515 | |
2516 eval { | |
2517 local $SIG{ALRM} = sub { die "timeout\n" }; | |
2518 local $SIG{PIPE} = sub { die "sigpipe\n" }; | |
2519 alarm(2); | |
2520 $s = IO::Socket::INET->new( | |
2521 Proto => 'tcp', | |
2522 PeerAddr => "127.0.0.1:$port", | |
2523 ); | |
650
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
2524 IO::Socket::SSL->start_SSL($s, |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
2525 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
2526 SSL_npn_protocols => $npn ? [ $npn ] : undef, |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
2527 SSL_alpn_protocols => $alpn ? [ $alpn ] : undef, |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
2528 SSL_error_trap => sub { die $_[1] } |
8a2cf558b8ae
Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
647
diff
changeset
|
2529 ) if $extra{'SSL'}; |
646 | 2530 alarm(0); |
2531 }; | |
2532 alarm(0); | |
2533 | |
2534 if ($@) { | |
2535 log_in("died: $@"); | |
2536 return undef; | |
2537 } | |
2538 | |
2539 return $s; | |
2540 } | |
2541 | |
2542 sub static_table { | |
2543 [ '', '' ], # unused | |
2544 [ ':authority', '' ], | |
2545 [ ':method', 'GET' ], | |
2546 [ ':method', 'POST' ], | |
2547 [ ':path', '/' ], | |
2548 [ ':path', '/index.html' ], | |
2549 [ ':scheme', 'http' ], | |
2550 [ ':scheme', 'https' ], | |
2551 [ ':status', '200' ], | |
2552 [ ':status', '204' ], | |
2553 [ ':status', '206' ], | |
2554 [ ':status', '304' ], | |
2555 [ ':status', '400' ], | |
2556 [ ':status', '404' ], | |
2557 [ ':status', '500' ], | |
2558 [ 'accept-charset', '' ], | |
2559 [ 'accept-encoding', 'gzip, deflate' ], | |
2560 [ 'accept-language', '' ], | |
2561 [ 'accept-ranges', '' ], | |
2562 [ 'accept', '' ], | |
2563 [ 'access-control-allow-origin', | |
2564 '' ], | |
2565 [ 'age', '' ], | |
2566 [ 'allow', '' ], | |
2567 [ 'authorization', '' ], | |
2568 [ 'cache-control', '' ], | |
2569 [ 'content-disposition', | |
2570 '' ], | |
2571 [ 'content-encoding', '' ], | |
2572 [ 'content-language', '' ], | |
2573 [ 'content-length', '' ], | |
2574 [ 'content-location', '' ], | |
2575 [ 'content-range', '' ], | |
2576 [ 'content-type', '' ], | |
2577 [ 'cookie', '' ], | |
2578 [ 'date', '' ], | |
2579 [ 'etag', '' ], | |
2580 [ 'expect', '' ], | |
2581 [ 'expires', '' ], | |
2582 [ 'from', '' ], | |
2583 [ 'host', '' ], | |
2584 [ 'if-match', '' ], | |
2585 [ 'if-modified-since', '' ], | |
2586 [ 'if-none-match', '' ], | |
2587 [ 'if-range', '' ], | |
2588 [ 'if-unmodified-since', | |
2589 '' ], | |
2590 [ 'last-modified', '' ], | |
2591 [ 'link', '' ], | |
2592 [ 'location', '' ], | |
2593 [ 'max-forwards', '' ], | |
2594 [ 'proxy-authenticate', '' ], | |
2595 [ 'proxy-authorization', | |
2596 '' ], | |
2597 [ 'range', '' ], | |
2598 [ 'referer', '' ], | |
2599 [ 'refresh', '' ], | |
2600 [ 'retry-after', '' ], | |
2601 [ 'server', '' ], | |
2602 [ 'set-cookie', '' ], | |
2603 [ 'strict-transport-security', | |
2604 '' ], | |
2605 [ 'transfer-encoding', '' ], | |
2606 [ 'user-agent', '' ], | |
2607 [ 'vary', '' ], | |
2608 [ 'via', '' ], | |
2609 [ 'www-authenticate', '' ], | |
2610 } | |
2611 | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2612 # RFC 7541, 5.1. Integer Representation |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2613 |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2614 sub ipack { |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2615 my ($base, $d) = @_; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2616 return sprintf("%.*b", $base, $d) if $d < 2**$base - 1; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2617 |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2618 my $o = sprintf("%${base}b", 2**$base - 1); |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2619 $d -= 2**$base - 1; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2620 while ($d >= 128) { |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2621 $o .= sprintf("%8b", $d % 128 + 128); |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2622 $d /= 128; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2623 } |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2624 $o .= sprintf("%08b", $d); |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2625 return $o; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2626 } |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2627 |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2628 sub iunpack { |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2629 my ($base, $b, $s) = @_; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2630 |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2631 my $len = unpack("\@$s B8", $b); $s++; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2632 my $prefix = substr($len, 0, 8 - $base); |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2633 $len = '0' x (8 - $base) . substr($len, 8 - $base); |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2634 $len = unpack("C", pack("B8", $len)); |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2635 |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2636 return ($len, $s, $prefix) if $len < 2**$base - 1; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2637 |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2638 my $m = 0; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2639 my $d; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2640 |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2641 do { |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2642 $d = unpack("\@$s C", $b); $s++; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2643 $len += ($d & 127) * 2**$m; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2644 $m += $base; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2645 } while (($d & 128) == 128); |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2646 |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2647 return ($len, $s, $prefix); |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2648 } |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2649 |
646 | 2650 sub hpack { |
2651 my ($ctx, $name, $value, %extra) = @_; | |
671
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2652 my $table = $ctx->{dynamic_encode}; |
646 | 2653 my $mode = defined $extra{mode} ? $extra{mode} : 1; |
2654 my $huff = $extra{huff}; | |
2655 | |
2656 my ($index, $buf) = 0; | |
2657 | |
2658 # 6.1. Indexed Header Field Representation | |
2659 | |
2660 if ($mode == 0) { | |
671
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2661 ++$index until $index > $#$table |
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2662 or $table->[$index][0] eq $name |
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2663 and $table->[$index][1] eq $value; |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2664 $buf = pack('B*', '1' . ipack(7, $index)); |
646 | 2665 } |
2666 | |
2667 # 6.2.1. Literal Header Field with Incremental Indexing | |
2668 | |
2669 if ($mode == 1) { | |
671
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2670 splice @$table, $ctx->{static_table_size}, 0, [ $name, $value ]; |
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2671 |
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2672 ++$index until $index > $#$table |
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2673 or $table->[$index][0] eq $name; |
646 | 2674 my $value = $huff ? huff($value) : $value; |
2675 | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2676 $buf = pack('B*', '01' . ipack(6, $index) |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2677 . ($huff ? '1' : '0') . ipack(7, length($value))); |
646 | 2678 $buf .= $value; |
2679 } | |
2680 | |
2681 # 6.2.1. Literal Header Field with Incremental Indexing -- New Name | |
2682 | |
2683 if ($mode == 2) { | |
671
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2684 splice @$table, $ctx->{static_table_size}, 0, [ $name, $value ]; |
646 | 2685 |
2686 my $name = $huff ? huff($name) : $name; | |
2687 my $value = $huff ? huff($value) : $value; | |
2688 my $hbit = ($huff ? '1' : '0'); | |
2689 | |
2690 $buf = pack('B*', '01000000'); | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2691 $buf .= pack('B*', $hbit . ipack(7, length($name))); |
646 | 2692 $buf .= $name; |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2693 $buf .= pack('B*', $hbit . ipack(7, length($value))); |
646 | 2694 $buf .= $value; |
2695 } | |
2696 | |
2697 # 6.2.2. Literal Header Field without Indexing | |
2698 | |
2699 if ($mode == 3) { | |
671
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2700 ++$index until $index > $#$table |
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2701 or $table->[$index][0] eq $name; |
646 | 2702 my $value = $huff ? huff($value) : $value; |
2703 | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2704 $buf = pack('B*', '0000' . ipack(4, $index) |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2705 . ($huff ? '1' : '0') . ipack(7, length($value))); |
646 | 2706 $buf .= $value; |
2707 } | |
2708 | |
2709 # 6.2.2. Literal Header Field without Indexing -- New Name | |
2710 | |
2711 if ($mode == 4) { | |
2712 my $name = $huff ? huff($name) : $name; | |
2713 my $value = $huff ? huff($value) : $value; | |
2714 my $hbit = ($huff ? '1' : '0'); | |
2715 | |
2716 $buf = pack('B*', '00000000'); | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2717 $buf .= pack('B*', $hbit . ipack(7, length($name))); |
646 | 2718 $buf .= $name; |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2719 $buf .= pack('B*', $hbit . ipack(7, length($value))); |
646 | 2720 $buf .= $value; |
2721 } | |
2722 | |
2723 # 6.2.3. Literal Header Field Never Indexed | |
2724 | |
2725 if ($mode == 5) { | |
671
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2726 ++$index until $index > $#$table |
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2727 or $table->[$index][0] eq $name; |
646 | 2728 my $value = $huff ? huff($value) : $value; |
2729 | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2730 $buf = pack('B*', '0001' . ipack(4, $index) |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2731 . ($huff ? '1' : '0') . ipack(7, length($value))); |
646 | 2732 $buf .= $value; |
2733 } | |
2734 | |
2735 # 6.2.3. Literal Header Field Never Indexed -- New Name | |
2736 | |
2737 if ($mode == 6) { | |
2738 my $name = $huff ? huff($name) : $name; | |
2739 my $value = $huff ? huff($value) : $value; | |
2740 my $hbit = ($huff ? '1' : '0'); | |
2741 | |
2742 $buf = pack('B*', '00010000'); | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2743 $buf .= pack('B*', $hbit . ipack(7, length($name))); |
646 | 2744 $buf .= $name; |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2745 $buf .= pack('B*', $hbit . ipack(7, length($value))); |
646 | 2746 $buf .= $value; |
2747 } | |
2748 | |
2749 return $buf; | |
2750 } | |
2751 | |
2752 sub hunpack { | |
2753 my ($ctx, $data, $length) = @_; | |
671
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2754 my $table = $ctx->{dynamic_decode}; |
646 | 2755 my %headers; |
2756 my $skip = 0; | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2757 my ($index, $name, $value); |
646 | 2758 |
735
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2759 my $field = sub { |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2760 my ($b) = @_; |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2761 my ($len, $s, $huff) = iunpack(7, @_); |
646 | 2762 |
2763 my $field = substr($b, $s, $len); | |
2764 $field = $huff ? dehuff($field) : $field; | |
2765 $s += $len; | |
2766 return ($field, $s); | |
735
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2767 }; |
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2768 |
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2769 my $add = sub { |
646 | 2770 my ($h, $n, $v) = @_; |
2771 return $h->{$n} = $v unless exists $h->{$n}; | |
717
3b6ff3b7367d
Tests: fixed multiple header field values representation in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
716
diff
changeset
|
2772 $h->{$n} = [ $h->{$n} ] unless ref $h->{$n}; |
647
4e36550410b3
Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
646
diff
changeset
|
2773 push @{$h->{$n}}, $v; |
735
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2774 }; |
646 | 2775 |
2776 while ($skip < $length) { | |
2777 my $ib = unpack("\@$skip B8", $data); | |
2778 | |
2779 if (substr($ib, 0, 1) eq '1') { | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2780 ($index, $skip) = iunpack(7, $data, $skip); |
735
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2781 $add->(\%headers, |
671
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2782 $table->[$index][0], $table->[$index][1]); |
646 | 2783 next; |
2784 } | |
2785 | |
2786 if (substr($ib, 0, 2) eq '01') { | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2787 ($index, $skip) = iunpack(6, $data, $skip); |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2788 $name = $table->[$index][0]; |
646 | 2789 |
735
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2790 ($name, $skip) = $field->($data, $skip) unless $name; |
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2791 ($value, $skip) = $field->($data, $skip); |
646 | 2792 |
671
0c70eb166a3a
Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
670
diff
changeset
|
2793 splice @$table, |
646 | 2794 $ctx->{static_table_size}, 0, [ $name, $value ]; |
735
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2795 $add->(\%headers, $name, $value); |
646 | 2796 next; |
2797 } | |
2798 | |
2799 if (substr($ib, 0, 4) eq '0000') { | |
694
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2800 ($index, $skip) = iunpack(4, $data, $skip); |
3eba6e1b8313
Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
692
diff
changeset
|
2801 $name = $table->[$index][0]; |
646 | 2802 |
735
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2803 ($name, $skip) = $field->($data, $skip) unless $name; |
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2804 ($value, $skip) = $field->($data, $skip); |
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2805 |
832cd7cc8f53
Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents:
730
diff
changeset
|
2806 $add->(\%headers, $name, $value); |
646 | 2807 next; |
2808 } | |
2809 } | |
2810 | |
2811 return \%headers; | |
2812 } | |
2813 | |
2814 sub huff_code { scalar { | |
2815 pack('C', 0) => '1111111111000', | |
2816 pack('C', 1) => '11111111111111111011000', | |
2817 pack('C', 2) => '1111111111111111111111100010', | |
2818 pack('C', 3) => '1111111111111111111111100011', | |
2819 pack('C', 4) => '1111111111111111111111100100', | |
2820 pack('C', 5) => '1111111111111111111111100101', | |
2821 pack('C', 6) => '1111111111111111111111100110', | |
2822 pack('C', 7) => '1111111111111111111111100111', | |
2823 pack('C', 8) => '1111111111111111111111101000', | |
2824 pack('C', 9) => '111111111111111111101010', | |
2825 pack('C', 10) => '111111111111111111111111111100', | |
2826 pack('C', 11) => '1111111111111111111111101001', | |
2827 pack('C', 12) => '1111111111111111111111101010', | |
2828 pack('C', 13) => '111111111111111111111111111101', | |
2829 pack('C', 14) => '1111111111111111111111101011', | |
2830 pack('C', 15) => '1111111111111111111111101100', | |
2831 pack('C', 16) => '1111111111111111111111101101', | |
2832 pack('C', 17) => '1111111111111111111111101110', | |
2833 pack('C', 18) => '1111111111111111111111101111', | |
2834 pack('C', 19) => '1111111111111111111111110000', | |
2835 pack('C', 20) => '1111111111111111111111110001', | |
2836 pack('C', 21) => '1111111111111111111111110010', | |
2837 pack('C', 22) => '111111111111111111111111111110', | |
2838 pack('C', 23) => '1111111111111111111111110011', | |
2839 pack('C', 24) => '1111111111111111111111110100', | |
2840 pack('C', 25) => '1111111111111111111111110101', | |
2841 pack('C', 26) => '1111111111111111111111110110', | |
2842 pack('C', 27) => '1111111111111111111111110111', | |
2843 pack('C', 28) => '1111111111111111111111111000', | |
2844 pack('C', 29) => '1111111111111111111111111001', | |
2845 pack('C', 30) => '1111111111111111111111111010', | |
2846 pack('C', 31) => '1111111111111111111111111011', | |
2847 pack('C', 32) => '010100', | |
2848 pack('C', 33) => '1111111000', | |
2849 pack('C', 34) => '1111111001', | |
2850 pack('C', 35) => '111111111010', | |
2851 pack('C', 36) => '1111111111001', | |
2852 pack('C', 37) => '010101', | |
2853 pack('C', 38) => '11111000', | |
2854 pack('C', 39) => '11111111010', | |
2855 pack('C', 40) => '1111111010', | |
2856 pack('C', 41) => '1111111011', | |
2857 pack('C', 42) => '11111001', | |
2858 pack('C', 43) => '11111111011', | |
2859 pack('C', 44) => '11111010', | |
2860 pack('C', 45) => '010110', | |
2861 pack('C', 46) => '010111', | |
2862 pack('C', 47) => '011000', | |
2863 pack('C', 48) => '00000', | |
2864 pack('C', 49) => '00001', | |
2865 pack('C', 50) => '00010', | |
2866 pack('C', 51) => '011001', | |
2867 pack('C', 52) => '011010', | |
2868 pack('C', 53) => '011011', | |
2869 pack('C', 54) => '011100', | |
2870 pack('C', 55) => '011101', | |
2871 pack('C', 56) => '011110', | |
2872 pack('C', 57) => '011111', | |
2873 pack('C', 58) => '1011100', | |
2874 pack('C', 59) => '11111011', | |
2875 pack('C', 60) => '111111111111100', | |
2876 pack('C', 61) => '100000', | |
2877 pack('C', 62) => '111111111011', | |
2878 pack('C', 63) => '1111111100', | |
2879 pack('C', 64) => '1111111111010', | |
2880 pack('C', 65) => '100001', | |
2881 pack('C', 66) => '1011101', | |
2882 pack('C', 67) => '1011110', | |
2883 pack('C', 68) => '1011111', | |
2884 pack('C', 69) => '1100000', | |
2885 pack('C', 70) => '1100001', | |
2886 pack('C', 71) => '1100010', | |
2887 pack('C', 72) => '1100011', | |
2888 pack('C', 73) => '1100100', | |
2889 pack('C', 74) => '1100101', | |
2890 pack('C', 75) => '1100110', | |
2891 pack('C', 76) => '1100111', | |
2892 pack('C', 77) => '1101000', | |
2893 pack('C', 78) => '1101001', | |
2894 pack('C', 79) => '1101010', | |
2895 pack('C', 80) => '1101011', | |
2896 pack('C', 81) => '1101100', | |
2897 pack('C', 82) => '1101101', | |
2898 pack('C', 83) => '1101110', | |
2899 pack('C', 84) => '1101111', | |
2900 pack('C', 85) => '1110000', | |
2901 pack('C', 86) => '1110001', | |
2902 pack('C', 87) => '1110010', | |
2903 pack('C', 88) => '11111100', | |
2904 pack('C', 89) => '1110011', | |
2905 pack('C', 90) => '11111101', | |
2906 pack('C', 91) => '1111111111011', | |
2907 pack('C', 92) => '1111111111111110000', | |
2908 pack('C', 93) => '1111111111100', | |
2909 pack('C', 94) => '11111111111100', | |
2910 pack('C', 95) => '100010', | |
2911 pack('C', 96) => '111111111111101', | |
2912 pack('C', 97) => '00011', | |
2913 pack('C', 98) => '100011', | |
2914 pack('C', 99) => '00100', | |
2915 pack('C', 100) => '100100', | |
2916 pack('C', 101) => '00101', | |
2917 pack('C', 102) => '100101', | |
2918 pack('C', 103) => '100110', | |
2919 pack('C', 104) => '100111', | |
2920 pack('C', 105) => '00110', | |
2921 pack('C', 106) => '1110100', | |
2922 pack('C', 107) => '1110101', | |
2923 pack('C', 108) => '101000', | |
2924 pack('C', 109) => '101001', | |
2925 pack('C', 110) => '101010', | |
2926 pack('C', 111) => '00111', | |
2927 pack('C', 112) => '101011', | |
2928 pack('C', 113) => '1110110', | |
2929 pack('C', 114) => '101100', | |
2930 pack('C', 115) => '01000', | |
2931 pack('C', 116) => '01001', | |
2932 pack('C', 117) => '101101', | |
2933 pack('C', 118) => '1110111', | |
2934 pack('C', 119) => '1111000', | |
2935 pack('C', 120) => '1111001', | |
2936 pack('C', 121) => '1111010', | |
2937 pack('C', 122) => '1111011', | |
2938 pack('C', 123) => '111111111111110', | |
2939 pack('C', 124) => '11111111100', | |
2940 pack('C', 125) => '11111111111101', | |
2941 pack('C', 126) => '1111111111101', | |
2942 pack('C', 127) => '1111111111111111111111111100', | |
2943 pack('C', 128) => '11111111111111100110', | |
2944 pack('C', 129) => '1111111111111111010010', | |
2945 pack('C', 130) => '11111111111111100111', | |
2946 pack('C', 131) => '11111111111111101000', | |
2947 pack('C', 132) => '1111111111111111010011', | |
2948 pack('C', 133) => '1111111111111111010100', | |
2949 pack('C', 134) => '1111111111111111010101', | |
2950 pack('C', 135) => '11111111111111111011001', | |
2951 pack('C', 136) => '1111111111111111010110', | |
2952 pack('C', 137) => '11111111111111111011010', | |
2953 pack('C', 138) => '11111111111111111011011', | |
2954 pack('C', 139) => '11111111111111111011100', | |
2955 pack('C', 140) => '11111111111111111011101', | |
2956 pack('C', 141) => '11111111111111111011110', | |
2957 pack('C', 142) => '111111111111111111101011', | |
2958 pack('C', 143) => '11111111111111111011111', | |
2959 pack('C', 144) => '111111111111111111101100', | |
2960 pack('C', 145) => '111111111111111111101101', | |
2961 pack('C', 146) => '1111111111111111010111', | |
2962 pack('C', 147) => '11111111111111111100000', | |
2963 pack('C', 148) => '111111111111111111101110', | |
2964 pack('C', 149) => '11111111111111111100001', | |
2965 pack('C', 150) => '11111111111111111100010', | |
2966 pack('C', 151) => '11111111111111111100011', | |
2967 pack('C', 152) => '11111111111111111100100', | |
2968 pack('C', 153) => '111111111111111011100', | |
2969 pack('C', 154) => '1111111111111111011000', | |
2970 pack('C', 155) => '11111111111111111100101', | |
2971 pack('C', 156) => '1111111111111111011001', | |
2972 pack('C', 157) => '11111111111111111100110', | |
2973 pack('C', 158) => '11111111111111111100111', | |
2974 pack('C', 159) => '111111111111111111101111', | |
2975 pack('C', 160) => '1111111111111111011010', | |
2976 pack('C', 161) => '111111111111111011101', | |
2977 pack('C', 162) => '11111111111111101001', | |
2978 pack('C', 163) => '1111111111111111011011', | |
2979 pack('C', 164) => '1111111111111111011100', | |
2980 pack('C', 165) => '11111111111111111101000', | |
2981 pack('C', 166) => '11111111111111111101001', | |
2982 pack('C', 167) => '111111111111111011110', | |
2983 pack('C', 168) => '11111111111111111101010', | |
2984 pack('C', 169) => '1111111111111111011101', | |
2985 pack('C', 170) => '1111111111111111011110', | |
2986 pack('C', 171) => '111111111111111111110000', | |
2987 pack('C', 172) => '111111111111111011111', | |
2988 pack('C', 173) => '1111111111111111011111', | |
2989 pack('C', 174) => '11111111111111111101011', | |
2990 pack('C', 175) => '11111111111111111101100', | |
2991 pack('C', 176) => '111111111111111100000', | |
2992 pack('C', 177) => '111111111111111100001', | |
2993 pack('C', 178) => '1111111111111111100000', | |
2994 pack('C', 179) => '111111111111111100010', | |
2995 pack('C', 180) => '11111111111111111101101', | |
2996 pack('C', 181) => '1111111111111111100001', | |
2997 pack('C', 182) => '11111111111111111101110', | |
2998 pack('C', 183) => '11111111111111111101111', | |
2999 pack('C', 184) => '11111111111111101010', | |
3000 pack('C', 185) => '1111111111111111100010', | |
3001 pack('C', 186) => '1111111111111111100011', | |
3002 pack('C', 187) => '1111111111111111100100', | |
3003 pack('C', 188) => '11111111111111111110000', | |
3004 pack('C', 189) => '1111111111111111100101', | |
3005 pack('C', 190) => '1111111111111111100110', | |
3006 pack('C', 191) => '11111111111111111110001', | |
3007 pack('C', 192) => '11111111111111111111100000', | |
3008 pack('C', 193) => '11111111111111111111100001', | |
3009 pack('C', 194) => '11111111111111101011', | |
3010 pack('C', 195) => '1111111111111110001', | |
3011 pack('C', 196) => '1111111111111111100111', | |
3012 pack('C', 197) => '11111111111111111110010', | |
3013 pack('C', 198) => '1111111111111111101000', | |
3014 pack('C', 199) => '1111111111111111111101100', | |
3015 pack('C', 200) => '11111111111111111111100010', | |
3016 pack('C', 201) => '11111111111111111111100011', | |
3017 pack('C', 202) => '11111111111111111111100100', | |
3018 pack('C', 203) => '111111111111111111111011110', | |
3019 pack('C', 204) => '111111111111111111111011111', | |
3020 pack('C', 205) => '11111111111111111111100101', | |
3021 pack('C', 206) => '111111111111111111110001', | |
3022 pack('C', 207) => '1111111111111111111101101', | |
3023 pack('C', 208) => '1111111111111110010', | |
3024 pack('C', 209) => '111111111111111100011', | |
3025 pack('C', 210) => '11111111111111111111100110', | |
3026 pack('C', 211) => '111111111111111111111100000', | |
3027 pack('C', 212) => '111111111111111111111100001', | |
3028 pack('C', 213) => '11111111111111111111100111', | |
3029 pack('C', 214) => '111111111111111111111100010', | |
3030 pack('C', 215) => '111111111111111111110010', | |
3031 pack('C', 216) => '111111111111111100100', | |
3032 pack('C', 217) => '111111111111111100101', | |
3033 pack('C', 218) => '11111111111111111111101000', | |
3034 pack('C', 219) => '11111111111111111111101001', | |
3035 pack('C', 220) => '1111111111111111111111111101', | |
3036 pack('C', 221) => '111111111111111111111100011', | |
3037 pack('C', 222) => '111111111111111111111100100', | |
3038 pack('C', 223) => '111111111111111111111100101', | |
3039 pack('C', 224) => '11111111111111101100', | |
3040 pack('C', 225) => '111111111111111111110011', | |
3041 pack('C', 226) => '11111111111111101101', | |
3042 pack('C', 227) => '111111111111111100110', | |
3043 pack('C', 228) => '1111111111111111101001', | |
3044 pack('C', 229) => '111111111111111100111', | |
3045 pack('C', 230) => '111111111111111101000', | |
3046 pack('C', 231) => '11111111111111111110011', | |
3047 pack('C', 232) => '1111111111111111101010', | |
3048 pack('C', 233) => '1111111111111111101011', | |
3049 pack('C', 234) => '1111111111111111111101110', | |
3050 pack('C', 235) => '1111111111111111111101111', | |
3051 pack('C', 236) => '111111111111111111110100', | |
3052 pack('C', 237) => '111111111111111111110101', | |
3053 pack('C', 238) => '11111111111111111111101010', | |
3054 pack('C', 239) => '11111111111111111110100', | |
3055 pack('C', 240) => '11111111111111111111101011', | |
3056 pack('C', 241) => '111111111111111111111100110', | |
3057 pack('C', 242) => '11111111111111111111101100', | |
3058 pack('C', 243) => '11111111111111111111101101', | |
3059 pack('C', 244) => '111111111111111111111100111', | |
3060 pack('C', 245) => '111111111111111111111101000', | |
3061 pack('C', 246) => '111111111111111111111101001', | |
3062 pack('C', 247) => '111111111111111111111101010', | |
3063 pack('C', 248) => '111111111111111111111101011', | |
3064 pack('C', 249) => '1111111111111111111111111110', | |
3065 pack('C', 250) => '111111111111111111111101100', | |
3066 pack('C', 251) => '111111111111111111111101101', | |
3067 pack('C', 252) => '111111111111111111111101110', | |
3068 pack('C', 253) => '111111111111111111111101111', | |
3069 pack('C', 254) => '111111111111111111111110000', | |
3070 pack('C', 255) => '11111111111111111111101110', | |
3071 '_eos' => '111111111111111111111111111111', | |
3072 }}; | |
3073 | |
3074 sub huff { | |
3075 my ($string) = @_; | |
3076 my $code = &huff_code; | |
3077 | |
3078 my $ret = join '', map { $code->{$_} } (split //, $string); | |
3079 my $len = length($ret) + (8 - length($ret) % 8); | |
3080 $ret .= $code->{_eos}; | |
3081 | |
3082 return pack("B$len", $ret); | |
3083 } | |
3084 | |
3085 sub dehuff { | |
3086 my ($string) = @_; | |
3087 my $code = &huff_code; | |
3088 my %decode = reverse %$code; | |
3089 | |
3090 my $ret = ''; my $c = ''; | |
3091 for (split //, unpack('B*', $string)) { | |
3092 $c .= $_; | |
3093 next unless exists $decode{$c}; | |
3094 last if $decode{$c} eq '_eos'; | |
3095 | |
3096 $ret .= $decode{$c}; | |
3097 $c = ''; | |
3098 } | |
3099 | |
3100 return $ret; | |
3101 } | |
3102 | |
3103 ############################################################################### | |
3104 | |
647
4e36550410b3
Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
646
diff
changeset
|
3105 sub gunzip_like { |
4e36550410b3
Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
646
diff
changeset
|
3106 my ($in, $re, $name) = @_; |
646 | 3107 |
3108 SKIP: { | |
3109 eval { require IO::Uncompress::Gunzip; }; | |
3110 Test::More::skip( | |
3111 "IO::Uncompress::Gunzip not installed", 1) if $@; | |
3112 | |
3113 my $out; | |
3114 | |
3115 IO::Uncompress::Gunzip::gunzip(\$in => \$out); | |
3116 | |
647
4e36550410b3
Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
646
diff
changeset
|
3117 like($out, $re, $name); |
646 | 3118 } |
3119 } | |
3120 | |
3121 ############################################################################### | |
3122 | |
3123 # for tests with multiple header fields | |
3124 | |
3125 sub http_daemon { | |
3126 my $server = IO::Socket::INET->new( | |
3127 Proto => 'tcp', | |
3128 LocalHost => '127.0.0.1', | |
3129 LocalPort => 8083, | |
3130 Listen => 5, | |
3131 Reuse => 1 | |
3132 ) | |
3133 or die "Can't create listening socket: $!\n"; | |
3134 | |
3135 local $SIG{PIPE} = 'IGNORE'; | |
3136 | |
3137 while (my $client = $server->accept()) { | |
3138 $client->autoflush(1); | |
3139 | |
3140 my $headers = ''; | |
3141 my $uri = ''; | |
3142 | |
3143 while (<$client>) { | |
3144 $headers .= $_; | |
3145 last if (/^\x0d?\x0a?$/); | |
3146 } | |
3147 | |
3148 next if $headers eq ''; | |
3149 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; | |
3150 | |
3151 if ($uri eq '/cookie') { | |
3152 | |
652
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
3153 my ($cookie, $cookie2) = $headers =~ /Cookie: (.+)/ig; |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
3154 $cookie2 = '' unless defined $cookie2; |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
3155 |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
3156 my ($cookie_a, $cookie_c) = ('', ''); |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
3157 $cookie_a = $1 if $headers =~ /X-Cookie-a: (.+)/i; |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
3158 $cookie_c = $1 if $headers =~ /X-Cookie-c: (.+)/i; |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
3159 |
646 | 3160 print $client <<EOF; |
3161 HTTP/1.1 200 OK | |
3162 Connection: close | |
652
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
3163 X-Sent-Cookie: $cookie |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
3164 X-Sent-Cookie2: $cookie2 |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
3165 X-Sent-Cookie-a: $cookie_a |
5a85ad9382a3
Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
651
diff
changeset
|
3166 X-Sent-Cookie-c: $cookie_c |
646 | 3167 |
3168 EOF | |
3169 | |
3170 } elsif ($uri eq '/set-cookie') { | |
3171 | |
3172 print $client <<EOF; | |
3173 HTTP/1.1 200 OK | |
3174 Connection: close | |
3175 Set-Cookie: a=b | |
3176 Set-Cookie: c=d | |
3177 | |
3178 EOF | |
3179 | |
3180 } | |
3181 | |
3182 } continue { | |
3183 close $client; | |
3184 } | |
3185 } | |
3186 | |
3187 ############################################################################### |