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