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