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