Mercurial > hg > nginx-tests
annotate grpc.t @ 1664:0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Starting with nginx 1.19.1, padding in response DATA frames could result in
"upstream sent response body larger than indicated content length" errors.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 24 Mar 2021 14:01:50 +0300 |
parents | 259dfb223f9a |
children | 816d6ceefe50 |
rev | line source |
---|---|
1303 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for grpc backend. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 use Test::Nginx::HTTP2; | |
20 | |
21 ############################################################################### | |
22 | |
23 select STDERR; $| = 1; | |
24 select STDOUT; $| = 1; | |
25 | |
1312
6f95c0ed2335
Tests: removed proxy prerequisite from grpc tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1303
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http rewrite http_v2 grpc/) |
1664
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
27 ->has(qw/upstream_keepalive/)->plan(116); |
1303 | 28 |
29 $t->write_file_expand('nginx.conf', <<'EOF'); | |
30 | |
31 %%TEST_GLOBALS%% | |
32 | |
33 daemon off; | |
34 | |
35 events { | |
36 } | |
37 | |
38 http { | |
39 %%TEST_GLOBALS_HTTP%% | |
40 | |
41 upstream u { | |
42 server 127.0.0.1:8081; | |
43 keepalive 1; | |
44 } | |
45 | |
46 server { | |
47 listen 127.0.0.1:8080 http2; | |
48 server_name localhost; | |
49 | |
50 http2_max_field_size 128k; | |
51 http2_max_header_size 128k; | |
52 http2_body_preread_size 128k; | |
1653
259dfb223f9a
Tests: compatibility with http2_max_header/field_size removal.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1631
diff
changeset
|
53 large_client_header_buffers 4 32k; |
1303 | 54 |
55 location / { | |
56 grpc_pass grpc://127.0.0.1:8081; | |
57 | |
58 if ($arg_if) { | |
59 # nothing | |
60 } | |
61 | |
62 limit_except GET { | |
63 # nothing | |
64 } | |
65 } | |
66 | |
67 location /KeepAlive { | |
68 grpc_pass u; | |
69 } | |
70 | |
71 location /LongHeader { | |
72 grpc_pass 127.0.0.1:8081; | |
73 grpc_set_header X-LongHeader $arg_h; | |
74 } | |
75 | |
76 location /LongField { | |
77 grpc_pass 127.0.0.1:8081; | |
78 grpc_buffer_size 65k; | |
79 } | |
80 | |
81 location /SetHost { | |
82 grpc_pass 127.0.0.1:8081; | |
83 grpc_set_header Host custom; | |
84 } | |
85 | |
86 location /SetArgs { | |
87 grpc_pass 127.0.0.1:8081; | |
88 set $args $arg_c; | |
89 } | |
90 } | |
91 } | |
92 | |
93 EOF | |
94 | |
1653
259dfb223f9a
Tests: compatibility with http2_max_header/field_size removal.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1631
diff
changeset
|
95 # suppress deprecation warning |
259dfb223f9a
Tests: compatibility with http2_max_header/field_size removal.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1631
diff
changeset
|
96 |
259dfb223f9a
Tests: compatibility with http2_max_header/field_size removal.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1631
diff
changeset
|
97 open OLDERR, ">&", \*STDERR; close STDERR; |
1381
97c8280de681
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1370
diff
changeset
|
98 $t->run(); |
1653
259dfb223f9a
Tests: compatibility with http2_max_header/field_size removal.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1631
diff
changeset
|
99 open STDERR, ">&", \*OLDERR; |
1303 | 100 |
101 ############################################################################### | |
102 | |
103 my $p = port(8081); | |
104 my $f = grpc(); | |
105 | |
106 my $frames = $f->{http_start}('/SayHello'); | |
107 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
108 is($frame->{flags}, 4, 'request - HEADERS flags'); | |
109 ok((my $sid = $frame->{sid}) % 2, 'request - HEADERS sid odd'); | |
110 is($frame->{headers}{':method'}, 'POST', 'request - method'); | |
111 is($frame->{headers}{':scheme'}, 'http', 'request - scheme'); | |
112 is($frame->{headers}{':path'}, '/SayHello', 'request - path'); | |
113 is($frame->{headers}{':authority'}, "127.0.0.1:$p", 'request - authority'); | |
114 is($frame->{headers}{'content-type'}, 'application/grpc', | |
115 'request - content type'); | |
116 is($frame->{headers}{te}, 'trailers', 'request - te'); | |
117 | |
118 $frames = $f->{data}('Hello'); | |
119 ($frame) = grep { $_->{type} eq "SETTINGS" } @$frames; | |
120 is($frame->{flags}, 1, 'request - SETTINGS ack'); | |
121 is($frame->{sid}, 0, 'request - SETTINGS sid'); | |
122 is($frame->{length}, 0, 'request - SETTINGS length'); | |
123 | |
124 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
125 is($frame->{data}, 'Hello', 'request - DATA'); | |
126 is($frame->{length}, 5, 'request - DATA length'); | |
127 is($frame->{flags}, 1, 'request - DATA flags'); | |
128 is($frame->{sid}, $sid, 'request - DATA sid match'); | |
129 | |
130 $frames = $f->{http_end}(); | |
131 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
132 is($frame->{flags}, 4, 'response - HEADERS flags'); | |
133 is($frame->{sid}, 1, 'response - HEADERS sid'); | |
134 is($frame->{headers}{':status'}, '200', 'response - status'); | |
135 is($frame->{headers}{'content-type'}, 'application/grpc', | |
136 'response - content type'); | |
137 ok($frame->{headers}{server}, 'response - server'); | |
138 ok($frame->{headers}{date}, 'response - date'); | |
139 ok(my $c = $frame->{headers}{'x-connection'}, 'response - connection'); | |
140 | |
141 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
142 is($frame->{data}, 'Hello world', 'response - DATA'); | |
143 is($frame->{length}, 11, 'response - DATA length'); | |
144 is($frame->{flags}, 0, 'response - DATA flags'); | |
145 is($frame->{sid}, 1, 'response - DATA sid'); | |
146 | |
147 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
148 is($frame->{flags}, 5, 'response - trailers flags'); | |
149 is($frame->{sid}, 1, 'response - trailers sid'); | |
150 is($frame->{headers}{'grpc-message'}, '', 'response - trailers message'); | |
151 is($frame->{headers}{'grpc-status'}, '0', 'response - trailers status'); | |
152 | |
153 # next request is on a new backend connection, no sid incremented | |
154 | |
155 $frames = $f->{http_start}('/SayHello'); | |
156 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
157 is($frame->{sid}, $sid, 'request 2 - HEADERS sid again'); | |
158 $f->{data}('Hello'); | |
159 $frames = $f->{http_end}(); | |
160 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
161 cmp_ok($frame->{headers}{'x-connection'}, '>', $c, 'response 2 - connection'); | |
162 | |
163 # upstream keepalive | |
164 | |
165 $frames = $f->{http_start}('/KeepAlive'); | |
166 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
167 is($frame->{sid}, $sid, 'keepalive - HEADERS sid'); | |
168 $f->{data}('Hello'); | |
169 $frames = $f->{http_end}(); | |
170 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
171 ok($c = $frame->{headers}{'x-connection'}, 'keepalive - connection'); | |
172 | |
173 $frames = $f->{http_start}('/KeepAlive', reuse => 1); | |
174 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
175 cmp_ok($frame->{sid}, '>', $sid, 'keepalive - HEADERS sid next'); | |
176 $f->{data}('Hello'); | |
177 $frames = $f->{http_end}(); | |
178 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
179 is($frame->{headers}{'x-connection'}, $c, 'keepalive - connection reuse'); | |
180 | |
1370
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
181 # upstream keepalive |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
182 # pending control frame ack after the response |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
183 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
184 undef $f; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
185 $f = grpc(); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
186 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
187 $frames = $f->{http_start}('/KeepAlive'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
188 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
189 is($frame->{sid}, $sid, 'keepalive 2 - HEADERS sid'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
190 $f->{data}('Hello'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
191 $f->{settings}(0, 1 => 4096); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
192 $frames = $f->{http_end}(); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
193 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
194 ok($c = $frame->{headers}{'x-connection'}, 'keepalive 2 - connection'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
195 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
196 $frames = $f->{http_start}('/KeepAlive', reuse => 1); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
197 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
198 ok($frame, 'upstream keepalive reused'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
199 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
200 cmp_ok($frame->{sid}, '>', $sid, 'keepalive 2 - HEADERS sid next'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
201 $f->{data}('Hello'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
202 $frames = $f->{http_end}(); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
203 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
204 is($frame->{headers}{'x-connection'}, $c, 'keepalive 2 - connection reuse'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
205 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
206 undef $f; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
207 $f = grpc(); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
208 |
1303 | 209 # various header compression formats |
210 | |
211 $f->{http_start}('/SayHello'); | |
212 $f->{data}('Hello'); | |
213 $frames = $f->{http_end}(mode => 3); | |
214 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
215 is($frame->{headers}{':status'}, '200', 'without indexing'); | |
216 is($frame->{headers}{'content-type'}, 'application/grpc', | |
217 'without indexing 2'); | |
218 | |
219 $f->{http_start}('/SayHello'); | |
220 $f->{data}('Hello'); | |
221 $frames = $f->{http_end}(mode => 4); | |
222 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
223 is($frame->{headers}{':status'}, '200', 'without indexing new'); | |
224 is($frame->{headers}{'content-type'}, 'application/grpc', | |
225 'without indexing new 2'); | |
226 | |
227 $f->{http_start}('/SayHello'); | |
228 $f->{data}('Hello'); | |
229 $frames = $f->{http_end}(mode => 5); | |
230 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
231 is($frame->{headers}{':status'}, '200', 'never indexed'); | |
232 is($frame->{headers}{'content-type'}, 'application/grpc', | |
233 'never indexed 2'); | |
234 | |
235 $f->{http_start}('/SayHello'); | |
236 $f->{data}('Hello'); | |
237 $frames = $f->{http_end}(mode => 6); | |
238 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
239 is($frame->{headers}{':status'}, '200', 'never indexed new'); | |
240 is($frame->{headers}{'content-type'}, 'application/grpc', | |
241 'never indexed new 2'); | |
242 | |
243 # padding & priority | |
244 | |
245 $f->{http_start}('/SayHello'); | |
246 $f->{data}('Hello'); | |
247 $frames = $f->{http_end}(padding => 7); | |
248 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
249 is($frame->{headers}{':status'}, '200', 'padding'); | |
250 | |
251 $f->{http_start}('/SayHello'); | |
252 $f->{data}('Hello'); | |
253 $frames = $f->{http_end}(prio => 137, dep => 0x01020304); | |
254 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
255 is($frame->{headers}{':status'}, '200', 'priority'); | |
256 | |
257 $f->{http_start}('/SayHello'); | |
258 $f->{data}('Hello'); | |
259 $frames = $f->{http_end}(padding => 7, prio => 137, dep => 0x01020304); | |
260 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
261 is($frame->{headers}{':status'}, '200', 'padding priority'); | |
262 | |
263 SKIP: { | |
264 skip 'long test', 1 unless $ENV{TEST_NGINX_UNSAFE}; | |
265 | |
266 $f->{http_start}('/SaySplit'); | |
267 $f->{data}('Hello'); | |
268 $frames = $f->{http_end}(padding => 7, prio => 137, dep => 0x01020304, | |
269 split => [(map{1}(1..20)), 30], split_delay => 0.1); | |
270 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
271 is($frame->{headers}{':status'}, '200', 'padding priority split'); | |
272 | |
273 } | |
274 | |
275 # grpc error, no empty data frame expected | |
276 | |
277 $f->{http_start}('/SayHello'); | |
278 $f->{data}('Hello'); | |
279 $frames = $f->{http_err}(); | |
280 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
281 is($frame->{flags}, 5, 'grpc error - HEADERS flags'); | |
282 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
283 ok(!$frame, 'grpc error - no DATA frame'); | |
284 | |
1583
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
285 # malformed response body length not equal to content-length |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
286 |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
287 TODO: { |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
288 local $TODO = 'not yet' unless $t->has_version('1.19.1'); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
289 |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
290 $f->{http_start}('/SayHello'); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
291 $f->{data}('Hello'); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
292 $frames = $f->{http_err2}(cl => 42); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
293 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
294 ok($frame, 'response body less than content-length'); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
295 |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
296 $f->{http_start}('/SayHello'); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
297 $f->{data}('Hello'); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
298 $frames = $f->{http_err2}(cl => 8); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
299 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
300 ok($frame, 'response body more than content-length'); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
301 |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
302 } |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
303 |
1303 | 304 # continuation from backend, expect parts assembled |
305 | |
306 $f->{http_start}('/SayHello'); | |
307 $f->{data}('Hello'); | |
308 $frames = $f->{continuation}(); | |
309 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
310 is($frame->{flags}, 4, 'continuation - HEADERS flags'); | |
311 is($frame->{headers}{':status'}, '200', 'continuation - status'); | |
312 is($frame->{headers}{'content-type'}, 'application/grpc', | |
313 'continuation - content type'); | |
314 | |
315 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
316 is($frame->{data}, 'Hello world', 'continuation - DATA'); | |
317 is($frame->{length}, 11, 'continuation - DATA length'); | |
318 is($frame->{flags}, 0, 'continuation - DATA flags'); | |
319 | |
320 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
321 is($frame->{flags}, 5, 'continuation - trailers flags'); | |
322 is($frame->{headers}{'grpc-message'}, '', 'continuation - trailers message'); | |
323 is($frame->{headers}{'grpc-status'}, '0', 'continuation - trailers status'); | |
324 | |
325 # continuation from backend, header split | |
326 | |
327 $f->{http_start}('/SayHello'); | |
328 $f->{data}('Hello'); | |
329 $frames = $f->{http_end}(mode => 6, continuation => [map { 1 } (1 .. 42)]); | |
330 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
331 is($frame->{headers}{':status'}, '200', 'continuation - header split'); | |
332 | |
333 # continuation to backend | |
334 | |
335 $frames = $f->{http_start}('/LongHeader?h=' . ('Z' x 31337)); | |
336 @$frames = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames; | |
337 is(@$frames, 4, 'continuation - frames'); | |
338 | |
339 $frame = shift @$frames; | |
340 is($frame->{type}, 'HEADERS', 'continuation - HEADERS'); | |
341 is($frame->{length}, 16384, 'continuation - HEADERS length'); | |
342 is($frame->{flags}, 1, 'continuation - HEADERS flags'); | |
343 ok($frame->{sid}, 'continuation - HEADERS sid'); | |
344 | |
345 $frame = shift @$frames; | |
346 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION'); | |
347 is($frame->{length}, 16384, 'continuation - CONTINUATION length'); | |
348 is($frame->{flags}, 0, 'continuation - CONTINUATION flags'); | |
349 ok($frame->{sid}, 'continuation - CONTINUATION sid'); | |
350 | |
351 $frame = shift @$frames; | |
352 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION 2'); | |
353 is($frame->{length}, 16384, 'continuation - CONTINUATION 2 length'); | |
354 is($frame->{flags}, 0, 'continuation - CONTINUATION 2 flags'); | |
355 | |
356 $frame = shift @$frames; | |
357 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION n'); | |
358 cmp_ok($frame->{length}, '<', 16384, 'continuation - CONTINUATION n length'); | |
359 is($frame->{flags}, 4, 'continuation - CONTINUATION n flags'); | |
360 is($frame->{headers}{':path'}, '/LongHeader?h=' . 'Z' x 31337, | |
361 'continuation - path'); | |
362 is($frame->{headers}{'x-longheader'}, 'Z' x 31337, 'continuation - header'); | |
363 | |
364 $f->{http_end}(); | |
365 | |
366 # long header field | |
367 | |
368 $f->{http_start}('/LongField'); | |
369 $f->{data}('Hello'); | |
370 $frames = $f->{field_len}(2**7); | |
371 ($frame) = grep { $_->{flags} & 0x4 } @$frames; | |
372 is($frame->{headers}{'x' x 2**7}, 'y' x 2**7, 'long header field 1'); | |
373 | |
374 $f->{http_start}('/LongField'); | |
375 $f->{data}('Hello'); | |
376 $frames = $f->{field_len}(2**8); | |
377 ($frame) = grep { $_->{flags} & 0x4 } @$frames; | |
378 is($frame->{headers}{'x' x 2**8}, 'y' x 2**8, 'long header field 2'); | |
379 | |
380 $f->{http_start}('/LongField'); | |
381 $f->{data}('Hello'); | |
382 $frames = $f->{field_len}(2**15); | |
383 ($frame) = grep { $_->{flags} & 0x4 } @$frames; | |
384 is($frame->{headers}{'x' x 2**15}, 'y' x 2**15, 'long header field 3'); | |
385 | |
386 # flow control | |
387 | |
388 $f->{http_start}('/FlowControl'); | |
389 $frames = $f->{data_len}(('Hello' x 13000) . ('x' x 550), 65535); | |
390 my $sum = eval join '+', map { $_->{type} eq "DATA" && $_->{length} } @$frames; | |
391 is($sum, 65535, 'flow control - iws length'); | |
392 | |
393 $f->{update}(10); | |
394 $f->{update_sid}(10); | |
395 | |
396 $frames = $f->{data_len}(undef, 10); | |
397 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
398 is($frame->{length}, 10, 'flow control - update length'); | |
399 is($frame->{flags}, 0, 'flow control - update flags'); | |
400 | |
401 $f->{update_sid}(10); | |
402 $f->{update}(10); | |
403 | |
404 $frames = $f->{data_len}(undef, 5); | |
405 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
406 is($frame->{length}, 5, 'flow control - rest length'); | |
407 is($frame->{flags}, 1, 'flow control - rest flags'); | |
408 | |
409 $f->{http_end}(); | |
410 | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
411 # preserve output |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
412 |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
413 $f->{http_start}('/Preserve'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
414 $f->{data}('Hello'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
415 $frames = $f->{http_pres}(); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
416 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
417 is($frame->{flags}, 4, 'preserve - HEADERS'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
418 |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
419 my @data = grep { $_->{type} eq "DATA" } @$frames; |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
420 $sum = eval join '+', map { $_->{length} } @data; |
1319
3b30e97acdcb
Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1318
diff
changeset
|
421 is($sum, 20480, 'preserve - DATA'); |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
422 |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
423 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
424 is($frame->{flags}, 5, 'preserve - trailers'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
425 |
1303 | 426 # DATA padding |
427 | |
428 $f->{http_start}('/SayPadding'); | |
429 $f->{data}('Hello'); | |
430 $frames = $f->{http_end}(body_padding => 42); | |
431 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
1362
6874b32dc3d2
Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1321
diff
changeset
|
432 is($frame->{data}, 'Hello world', 'DATA padding'); |
6874b32dc3d2
Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1321
diff
changeset
|
433 is($frame->{length}, 11, 'DATA padding - length'); |
6874b32dc3d2
Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1321
diff
changeset
|
434 is($frame->{flags}, 0, 'DATA padding - flags'); |
1303 | 435 |
1664
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
436 # DATA padding with Content-Length |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
437 |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
438 TODO: { |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
439 local $TODO = 'not yet' |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
440 if $t->has_version('1.19.1') and !$t->has_version('1.19.9'); |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
441 |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
442 $f->{http_start}('/SayPadding'); |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
443 $f->{data}('Hello'); |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
444 $frames = $f->{http_end}(body_padding => 42, cl => length('Hello world')); |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
445 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
446 is($frame->{data}, 'Hello world', 'DATA padding cl'); |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
447 is($frame->{length}, 11, 'DATA padding cl - length'); |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
448 is($frame->{flags}, 0, 'DATA padding cl - flags'); |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
449 |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
450 } |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
451 |
1303 | 452 # :authority inheritance |
453 | |
454 $frames = $f->{http_start}('/SayHello?if=1'); | |
455 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
456 is($frame->{headers}{':authority'}, "127.0.0.1:$p", 'authority in if'); | |
457 $f->{data}('Hello'); | |
458 $f->{http_end}(); | |
459 | |
460 # misc tests | |
461 | |
462 $frames = $f->{http_start}('/SetHost'); | |
463 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
464 ok(!$frame->{headers}{':authority'}, 'set host - authority'); | |
465 is($frame->{headers}{'host'}, 'custom', 'set host - host'); | |
466 $f->{data}('Hello'); | |
467 $f->{http_end}(); | |
468 | |
469 $frames = $f->{http_start}('/SetArgs?f'); | |
470 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
471 is($frame->{headers}{':path'}, '/SetArgs', 'set args'); | |
472 $f->{data}('Hello'); | |
473 $f->{http_end}(); | |
474 | |
475 $frames = $f->{http_start}('/SetArgs?c=1'); | |
476 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
477 is($frame->{headers}{':path'}, '/SetArgs?1', 'set args len'); | |
478 $f->{data}('Hello'); | |
479 $f->{http_end}(); | |
480 | |
481 $frames = $f->{http_start}('/SetArgs esc'); | |
482 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
483 is($frame->{headers}{':path'}, '/SetArgs%20esc', 'uri escape'); | |
484 $f->{data}('Hello'); | |
485 $f->{http_end}(); | |
486 | |
487 $frames = $f->{http_start}('/'); | |
488 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
489 is($frame->{headers}{':path'}, '/', 'root index'); | |
490 $f->{data}('Hello'); | |
491 $f->{http_end}(); | |
492 | |
493 $frames = $f->{http_start}('/', method => 'GET'); | |
494 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
495 is($frame->{headers}{':method'}, 'GET', 'method get'); | |
496 $f->{data}('Hello'); | |
497 $f->{http_end}(); | |
498 | |
499 $frames = $f->{http_start}('/', method => 'HEAD'); | |
500 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
501 is($frame->{headers}{':method'}, 'HEAD', 'method head'); | |
502 $f->{data}('Hello'); | |
503 $f->{http_end}(); | |
504 | |
1564
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
505 TODO: { |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
506 local $TODO = 'not yet' unless $t->has_version('1.19.0'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
507 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
508 # receiving END_STREAM followed by WINDOW_UPDATE on incomplete request body |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
509 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
510 $f->{http_start}('/Discard_WU'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
511 $frames = $f->{discard}(); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
512 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
513 is($frame->{flags}, 5, 'discard WINDOW_UPDATE - trailers'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
514 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
515 # receiving END_STREAM followed by RST_STREAM NO_ERROR |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
516 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
517 $f->{http_start}('/Discard_NE'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
518 $frames = $f->{discard}(); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
519 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
520 is($frame->{flags}, 5, 'discard NO_ERROR - trailers'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
521 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
522 } |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
523 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
524 # receiving END_STREAM followed by several RST_STREAM NO_ERROR |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
525 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
526 $f->{http_start}('/Discard_NE3'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
527 $frames = $f->{discard}(); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
528 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
529 is($frame->{flags}, undef, 'discard NO_ERROR many - no trailers'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
530 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
531 # receiving END_STREAM followed by RST_STREAM CANCEL |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
532 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
533 $f->{http_start}('/Discard_CNL'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
534 $frames = $f->{discard}(); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
535 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
536 is($frame->{flags}, undef, 'discard CANCEL - no trailers'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
537 |
1631
62a1667f60f8
Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1624
diff
changeset
|
538 undef $f; |
62a1667f60f8
Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1624
diff
changeset
|
539 $f = grpc(); |
62a1667f60f8
Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1624
diff
changeset
|
540 |
1624
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
541 # upstream keepalive, grpc error |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
542 # receiving END_STREAM followed by RST_STREAM NO_ERROR |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
543 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
544 $f->{http_start}('/KeepAlive'); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
545 $f->{data}('Hello'); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
546 $frames = $f->{http_err_rst}(); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
547 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
548 ok($frame->{headers}{'grpc-status'}, 'keepalive 3 - grpc error, rst'); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
549 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
550 $frames = $f->{http_start}('/KeepAlive', reuse => 1); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
551 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
552 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
553 TODO: { |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
554 local $TODO = 'not yet' unless $t->has_version('1.19.5'); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
555 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
556 ok($frame, 'keepalive 3 - connection reused'); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
557 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
558 } |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
559 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
560 undef $f; |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
561 $f = grpc(); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
562 |
1303 | 563 ############################################################################### |
564 | |
565 sub grpc { | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
566 my ($server, $client, $f, $s, $c, $sid, $csid, $uri); |
1303 | 567 my $n = 0; |
568 | |
569 $server = IO::Socket::INET->new( | |
570 Proto => 'tcp', | |
571 LocalHost => '127.0.0.1', | |
572 LocalPort => $p, | |
573 Listen => 5, | |
574 Reuse => 1 | |
575 ) | |
576 or die "Can't create listening socket: $!\n"; | |
577 | |
578 $f->{http_start} = sub { | |
579 ($uri, my %extra) = @_; | |
580 my $body_more = 1 if $uri !~ /LongHeader/; | |
581 my $meth = $extra{method} || 'POST'; | |
582 $s = Test::Nginx::HTTP2->new() if !defined $s; | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
583 $csid = $s->new_stream({ body_more => $body_more, headers => [ |
1303 | 584 { name => ':method', value => $meth, mode => !!$meth }, |
585 { name => ':scheme', value => 'http', mode => 0 }, | |
586 { name => ':path', value => $uri, }, | |
587 { name => ':authority', value => 'localhost' }, | |
588 { name => 'content-type', value => 'application/grpc' }, | |
589 { name => 'te', value => 'trailers', mode => 2 }]}); | |
590 | |
591 if (!$extra{reuse}) { | |
1321
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
592 eval { |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
593 local $SIG{ALRM} = sub { die "timeout\n" }; |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
594 alarm(5); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
595 |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
596 $client = $server->accept() or return; |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
597 |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
598 alarm(0); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
599 }; |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
600 alarm(0); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
601 if ($@) { |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
602 log_in("died: $@"); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
603 return undef; |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
604 } |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
605 |
1303 | 606 log2c("(new connection $client)"); |
607 $n++; | |
608 | |
609 $client->sysread(my $buf, 24) == 24 or return; # preface | |
610 | |
611 $c = Test::Nginx::HTTP2->new(1, socket => $client, | |
612 pure => 1, preface => "") or return; | |
613 } | |
614 | |
615 my $frames = $c->read(all => [{ fin => 4 }]); | |
616 | |
617 if (!$extra{reuse}) { | |
618 $c->h2_settings(0); | |
619 $c->h2_settings(1); | |
620 } | |
621 | |
622 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
623 $sid = $frame->{sid}; | |
624 return $frames; | |
625 }; | |
626 $f->{data} = sub { | |
627 my ($body, %extra) = @_; | |
628 $s->h2_body($body, { %extra }); | |
629 return $c->read(all => [{ sid => $sid, | |
630 length => length($body) }]); | |
631 }; | |
632 $f->{data_len} = sub { | |
633 my ($body, $len) = @_; | |
634 $s->h2_body($body) if defined $body; | |
635 return $c->read(all => [{ sid => $sid, length => $len }]); | |
636 }; | |
637 $f->{update} = sub { | |
638 $c->h2_window(shift); | |
639 }; | |
640 $f->{update_sid} = sub { | |
641 $c->h2_window(shift, $sid); | |
642 }; | |
1370
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
643 $f->{settings} = sub { |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
644 $c->h2_settings(@_); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
645 }; |
1303 | 646 $f->{http_end} = sub { |
647 my (%extra) = @_; | |
1664
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
648 my $h = [ |
1303 | 649 { name => ':status', value => '200', |
650 mode => $extra{mode} || 0 }, | |
651 { name => 'content-type', value => 'application/grpc', | |
652 mode => $extra{mode} || 1, huff => 1 }, | |
653 { name => 'x-connection', value => $n, | |
1664
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
654 mode => 2, huff => 1 }]; |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
655 push @$h, { name => 'content-length', value => $extra{cl} } |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
656 if $extra{cl}; |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
657 $c->new_stream({ body_more => 1, headers => $h, %extra }, $sid); |
1303 | 658 $c->h2_body('Hello world', { body_more => 1, |
659 body_padding => $extra{body_padding} }); | |
660 $c->new_stream({ headers => [ | |
661 { name => 'grpc-status', value => '0', | |
662 mode => 2, huff => 1 }, | |
663 { name => 'grpc-message', value => '', | |
664 mode => 2, huff => 1 }, | |
665 ]}, $sid); | |
666 | |
667 return $s->read(all => [{ fin => 1 }]); | |
668 }; | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
669 $f->{http_pres} = sub { |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
670 my (%extra) = @_; |
1319
3b30e97acdcb
Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1318
diff
changeset
|
671 $s->h2_settings(0, 0x4 => 8192); |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
672 $c->new_stream({ body_more => 1, %extra, headers => [ |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
673 { name => ':status', value => '200', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
674 mode => $extra{mode} || 0 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
675 { name => 'content-type', value => 'application/grpc', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
676 mode => $extra{mode} || 1, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
677 { name => 'x-connection', value => $n, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
678 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
679 ]}, $sid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
680 for (1 .. 20) { |
1319
3b30e97acdcb
Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1318
diff
changeset
|
681 $c->h2_body(sprintf('Hello %02d', $_) x 128, { |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
682 body_more => 1, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
683 body_padding => $extra{body_padding} }); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
684 $c->h2_ping("PING"); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
685 } |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
686 # reopen window |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
687 $s->h2_window(2**24); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
688 $s->h2_window(2**24, $csid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
689 $c->new_stream({ headers => [ |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
690 { name => 'grpc-status', value => '0', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
691 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
692 { name => 'grpc-message', value => '', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
693 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
694 ]}, $sid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
695 |
1319
3b30e97acdcb
Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1318
diff
changeset
|
696 return $s->read(all => [{ sid => $csid, fin => 1 }]); |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
697 }; |
1303 | 698 $f->{http_err} = sub { |
699 $c->new_stream({ headers => [ | |
700 { name => ':status', value => '200', mode => 0 }, | |
701 { name => 'content-type', value => 'application/grpc', | |
702 mode => 1, huff => 1 }, | |
703 { name => 'grpc-status', value => '12', | |
704 mode => 2, huff => 1 }, | |
705 { name => 'grpc-message', value => 'unknown service', | |
706 mode => 2, huff => 1 }, | |
707 ]}, $sid); | |
708 | |
709 return $s->read(all => [{ fin => 1 }]); | |
710 }; | |
1624
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
711 $f->{http_err_rst} = sub { |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
712 $c->start_chain(); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
713 $c->new_stream({ headers => [ |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
714 { name => ':status', value => '200', mode => 0 }, |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
715 { name => 'content-type', value => 'application/grpc' }, |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
716 { name => 'grpc-status', value => '12', mode => 2 }, |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
717 { name => 'grpc-message', value => 'unknown service', |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
718 mode => 2 }, |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
719 ]}, $sid); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
720 $c->h2_rst($sid, 0); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
721 $c->send_chain(); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
722 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
723 return $s->read(all => [{ fin => 1 }]); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
724 }; |
1583
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
725 $f->{http_err2} = sub { |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
726 my %extra = @_; |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
727 $c->new_stream({ body_more => 1, headers => [ |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
728 { name => ':status', value => '200', mode => 0 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
729 { name => 'content-type', value => 'application/grpc', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
730 mode => 1, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
731 { name => 'content-length', value => $extra{cl}, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
732 mode => 1, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
733 ]}, $sid); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
734 $c->h2_body('Hello world', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
735 { body_more => 1, body_split => [5] }); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
736 $c->new_stream({ headers => [ |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
737 { name => 'grpc-status', value => '0', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
738 mode => 2, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
739 { name => 'grpc-message', value => '', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
740 mode => 2, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
741 ]}, $sid); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
742 |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
743 return $s->read(all => [{ type => 'RST_STREAM' }]); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
744 }; |
1303 | 745 $f->{continuation} = sub { |
746 $c->new_stream({ continuation => 1, body_more => 1, headers => [ | |
747 { name => ':status', value => '200', mode => 0 }, | |
748 ]}, $sid); | |
749 $c->h2_continue($sid, { continuation => 1, headers => [ | |
750 { name => 'content-type', value => 'application/grpc', | |
751 mode => 1, huff => 1 }, | |
752 ]}); | |
753 $c->h2_continue($sid, { headers => [ | |
754 # an empty CONTINUATION frame is legitimate | |
755 ]}); | |
756 $c->h2_body('Hello world', { body_more => 1 }); | |
757 $c->new_stream({ continuation => 1, headers => [ | |
758 { name => 'grpc-status', value => '0', | |
759 mode => 2, huff => 1 }, | |
760 ]}, $sid); | |
761 $c->h2_continue($sid, { headers => [ | |
762 { name => 'grpc-message', value => '', | |
763 mode => 2, huff => 1 }, | |
764 ]}); | |
765 | |
766 return $s->read(all => [{ fin => 1 }]); | |
767 }; | |
768 $f->{field_len} = sub { | |
769 my ($len) = @_; | |
770 $c->new_stream({ continuation => [map {2**14} (0..$len/2**13)], | |
771 body_more => 1, headers => [ | |
772 { name => ':status', value => '200', mode => 0 }, | |
773 { name => 'content-type', value => 'application/grpc', | |
774 mode => 1, huff => 1 }, | |
775 { name => 'x' x $len, value => 'y' x $len, mode => 6 }, | |
776 ]}, $sid); | |
777 $c->h2_body('Hello world', { body_more => 1 }); | |
778 $c->new_stream({ headers => [ | |
779 { name => 'grpc-status', value => '0', | |
780 mode => 2, huff => 1 }, | |
781 { name => 'grpc-message', value => '', | |
782 mode => 2, huff => 1 }, | |
783 ]}, $sid); | |
784 | |
785 return $s->read(all => [{ fin => 1 }]); | |
786 }; | |
1564
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
787 $f->{discard} = sub { |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
788 my (%extra) = @_; |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
789 $c->new_stream({ body_more => 1, %extra, headers => [ |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
790 { name => ':status', value => '200', |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
791 mode => $extra{mode} || 0 }, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
792 { name => 'content-type', value => 'application/grpc', |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
793 mode => $extra{mode} || 1, huff => 1 }, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
794 { name => 'x-connection', value => $n, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
795 mode => 2, huff => 1 }, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
796 ]}, $sid); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
797 $c->h2_body('Hello world', { body_more => 1, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
798 body_padding => $extra{body_padding} }); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
799 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
800 # stick trailers and subsequent frames for reproducibility |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
801 |
1623
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
802 $c->start_chain(); |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
803 $c->new_stream({ headers => [ |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
804 { name => 'grpc-status', value => '0', mode => 2 } |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
805 ]}, $sid); |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
806 $c->h2_window(42, $sid) if $uri eq '/Discard_WU'; |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
807 $c->h2_rst($sid, 0) if $uri eq '/Discard_NE'; |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
808 $c->h2_rst($sid, 0), $c->h2_rst($sid, 0), $c->h2_rst($sid, 0) |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
809 if $uri eq '/Discard_NE3'; |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
810 $c->h2_rst($sid, 8) if $uri eq '/Discard_CNL'; |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
811 $c->send_chain(); |
1564
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
812 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
813 return $s->read(all => [{ fin => 1 }], wait => 2) |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
814 if $uri eq '/Discard_WU' || $uri eq '/Discard_NE'; |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
815 return $s->read(all => [{ type => 'RST_STREAM' }]); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
816 }; |
1303 | 817 return $f; |
818 } | |
819 | |
820 sub log2i { Test::Nginx::log_core('|| <<', @_); } | |
821 sub log2o { Test::Nginx::log_core('|| >>', @_); } | |
822 sub log2c { Test::Nginx::log_core('||', @_); } | |
823 | |
824 ############################################################################### |