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