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