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