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