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