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