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