Mercurial > hg > nginx-tests
annotate grpc.t @ 1653:259dfb223f9a
Tests: compatibility with http2_max_header/field_size removal.
Tests are adjusted to equally fit in limits set by both old and new ways:
http2_max_header_size / http2_max_field_size and large_client_header_buffers.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 10 Feb 2021 15:13:22 +0300 |
parents | 62a1667f60f8 |
children | 0fae67763be5 |
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/) |
1624
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
27 ->has(qw/upstream_keepalive/)->plan(113); |
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 |
436 # :authority inheritance | |
437 | |
438 $frames = $f->{http_start}('/SayHello?if=1'); | |
439 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
440 is($frame->{headers}{':authority'}, "127.0.0.1:$p", 'authority in if'); | |
441 $f->{data}('Hello'); | |
442 $f->{http_end}(); | |
443 | |
444 # misc tests | |
445 | |
446 $frames = $f->{http_start}('/SetHost'); | |
447 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
448 ok(!$frame->{headers}{':authority'}, 'set host - authority'); | |
449 is($frame->{headers}{'host'}, 'custom', 'set host - host'); | |
450 $f->{data}('Hello'); | |
451 $f->{http_end}(); | |
452 | |
453 $frames = $f->{http_start}('/SetArgs?f'); | |
454 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
455 is($frame->{headers}{':path'}, '/SetArgs', 'set args'); | |
456 $f->{data}('Hello'); | |
457 $f->{http_end}(); | |
458 | |
459 $frames = $f->{http_start}('/SetArgs?c=1'); | |
460 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
461 is($frame->{headers}{':path'}, '/SetArgs?1', 'set args len'); | |
462 $f->{data}('Hello'); | |
463 $f->{http_end}(); | |
464 | |
465 $frames = $f->{http_start}('/SetArgs esc'); | |
466 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
467 is($frame->{headers}{':path'}, '/SetArgs%20esc', 'uri escape'); | |
468 $f->{data}('Hello'); | |
469 $f->{http_end}(); | |
470 | |
471 $frames = $f->{http_start}('/'); | |
472 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
473 is($frame->{headers}{':path'}, '/', 'root index'); | |
474 $f->{data}('Hello'); | |
475 $f->{http_end}(); | |
476 | |
477 $frames = $f->{http_start}('/', method => 'GET'); | |
478 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
479 is($frame->{headers}{':method'}, 'GET', 'method get'); | |
480 $f->{data}('Hello'); | |
481 $f->{http_end}(); | |
482 | |
483 $frames = $f->{http_start}('/', method => 'HEAD'); | |
484 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
485 is($frame->{headers}{':method'}, 'HEAD', 'method head'); | |
486 $f->{data}('Hello'); | |
487 $f->{http_end}(); | |
488 | |
1564
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
489 TODO: { |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
490 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
|
491 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
492 # 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
|
493 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
494 $f->{http_start}('/Discard_WU'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
495 $frames = $f->{discard}(); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
496 (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
|
497 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
|
498 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
499 # 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
|
500 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
501 $f->{http_start}('/Discard_NE'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
502 $frames = $f->{discard}(); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
503 (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
|
504 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
|
505 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
506 } |
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 several RST_STREAM NO_ERROR |
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_NE3'); |
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}, 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
|
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 CANCEL |
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_CNL'); |
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}, undef, 'discard CANCEL - no trailers'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
521 |
1631
62a1667f60f8
Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1624
diff
changeset
|
522 undef $f; |
62a1667f60f8
Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1624
diff
changeset
|
523 $f = grpc(); |
62a1667f60f8
Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1624
diff
changeset
|
524 |
1624
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
525 # 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
|
526 # 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
|
527 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
528 $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
|
529 $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
|
530 $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
|
531 ($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
|
532 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
|
533 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
534 $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
|
535 ($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
|
536 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
537 TODO: { |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
538 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
|
539 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
540 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
|
541 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
542 } |
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 undef $f; |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
545 $f = grpc(); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
546 |
1303 | 547 ############################################################################### |
548 | |
549 sub grpc { | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
550 my ($server, $client, $f, $s, $c, $sid, $csid, $uri); |
1303 | 551 my $n = 0; |
552 | |
553 $server = IO::Socket::INET->new( | |
554 Proto => 'tcp', | |
555 LocalHost => '127.0.0.1', | |
556 LocalPort => $p, | |
557 Listen => 5, | |
558 Reuse => 1 | |
559 ) | |
560 or die "Can't create listening socket: $!\n"; | |
561 | |
562 $f->{http_start} = sub { | |
563 ($uri, my %extra) = @_; | |
564 my $body_more = 1 if $uri !~ /LongHeader/; | |
565 my $meth = $extra{method} || 'POST'; | |
566 $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
|
567 $csid = $s->new_stream({ body_more => $body_more, headers => [ |
1303 | 568 { name => ':method', value => $meth, mode => !!$meth }, |
569 { name => ':scheme', value => 'http', mode => 0 }, | |
570 { name => ':path', value => $uri, }, | |
571 { name => ':authority', value => 'localhost' }, | |
572 { name => 'content-type', value => 'application/grpc' }, | |
573 { name => 'te', value => 'trailers', mode => 2 }]}); | |
574 | |
575 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
|
576 eval { |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
577 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
|
578 alarm(5); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
579 |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
580 $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
|
581 |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
582 alarm(0); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
583 }; |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
584 alarm(0); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
585 if ($@) { |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
586 log_in("died: $@"); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
587 return undef; |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
588 } |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
589 |
1303 | 590 log2c("(new connection $client)"); |
591 $n++; | |
592 | |
593 $client->sysread(my $buf, 24) == 24 or return; # preface | |
594 | |
595 $c = Test::Nginx::HTTP2->new(1, socket => $client, | |
596 pure => 1, preface => "") or return; | |
597 } | |
598 | |
599 my $frames = $c->read(all => [{ fin => 4 }]); | |
600 | |
601 if (!$extra{reuse}) { | |
602 $c->h2_settings(0); | |
603 $c->h2_settings(1); | |
604 } | |
605 | |
606 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
607 $sid = $frame->{sid}; | |
608 return $frames; | |
609 }; | |
610 $f->{data} = sub { | |
611 my ($body, %extra) = @_; | |
612 $s->h2_body($body, { %extra }); | |
613 return $c->read(all => [{ sid => $sid, | |
614 length => length($body) }]); | |
615 }; | |
616 $f->{data_len} = sub { | |
617 my ($body, $len) = @_; | |
618 $s->h2_body($body) if defined $body; | |
619 return $c->read(all => [{ sid => $sid, length => $len }]); | |
620 }; | |
621 $f->{update} = sub { | |
622 $c->h2_window(shift); | |
623 }; | |
624 $f->{update_sid} = sub { | |
625 $c->h2_window(shift, $sid); | |
626 }; | |
1370
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
627 $f->{settings} = sub { |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
628 $c->h2_settings(@_); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
629 }; |
1303 | 630 $f->{http_end} = sub { |
631 my (%extra) = @_; | |
632 $c->new_stream({ body_more => 1, %extra, headers => [ | |
633 { name => ':status', value => '200', | |
634 mode => $extra{mode} || 0 }, | |
635 { name => 'content-type', value => 'application/grpc', | |
636 mode => $extra{mode} || 1, huff => 1 }, | |
637 { name => 'x-connection', value => $n, | |
638 mode => 2, huff => 1 }, | |
639 ]}, $sid); | |
640 $c->h2_body('Hello world', { body_more => 1, | |
641 body_padding => $extra{body_padding} }); | |
642 $c->new_stream({ headers => [ | |
643 { name => 'grpc-status', value => '0', | |
644 mode => 2, huff => 1 }, | |
645 { name => 'grpc-message', value => '', | |
646 mode => 2, huff => 1 }, | |
647 ]}, $sid); | |
648 | |
649 return $s->read(all => [{ fin => 1 }]); | |
650 }; | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
651 $f->{http_pres} = sub { |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
652 my (%extra) = @_; |
1319
3b30e97acdcb
Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1318
diff
changeset
|
653 $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
|
654 $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
|
655 { name => ':status', value => '200', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
656 mode => $extra{mode} || 0 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
657 { name => 'content-type', value => 'application/grpc', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
658 mode => $extra{mode} || 1, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
659 { name => 'x-connection', value => $n, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
660 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
661 ]}, $sid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
662 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
|
663 $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
|
664 body_more => 1, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
665 body_padding => $extra{body_padding} }); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
666 $c->h2_ping("PING"); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
667 } |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
668 # reopen window |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
669 $s->h2_window(2**24); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
670 $s->h2_window(2**24, $csid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
671 $c->new_stream({ headers => [ |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
672 { name => 'grpc-status', value => '0', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
673 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
674 { name => 'grpc-message', value => '', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
675 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
676 ]}, $sid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
677 |
1319
3b30e97acdcb
Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1318
diff
changeset
|
678 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
|
679 }; |
1303 | 680 $f->{http_err} = sub { |
681 $c->new_stream({ headers => [ | |
682 { name => ':status', value => '200', mode => 0 }, | |
683 { name => 'content-type', value => 'application/grpc', | |
684 mode => 1, huff => 1 }, | |
685 { name => 'grpc-status', value => '12', | |
686 mode => 2, huff => 1 }, | |
687 { name => 'grpc-message', value => 'unknown service', | |
688 mode => 2, huff => 1 }, | |
689 ]}, $sid); | |
690 | |
691 return $s->read(all => [{ fin => 1 }]); | |
692 }; | |
1624
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
693 $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
|
694 $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
|
695 $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
|
696 { 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
|
697 { 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
|
698 { 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
|
699 { 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
|
700 mode => 2 }, |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
701 ]}, $sid); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
702 $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
|
703 $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
|
704 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
705 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
|
706 }; |
1583
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
707 $f->{http_err2} = sub { |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
708 my %extra = @_; |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
709 $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
|
710 { name => ':status', value => '200', mode => 0 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
711 { name => 'content-type', value => 'application/grpc', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
712 mode => 1, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
713 { name => 'content-length', value => $extra{cl}, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
714 mode => 1, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
715 ]}, $sid); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
716 $c->h2_body('Hello world', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
717 { body_more => 1, body_split => [5] }); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
718 $c->new_stream({ headers => [ |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
719 { name => 'grpc-status', value => '0', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
720 mode => 2, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
721 { name => 'grpc-message', value => '', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
722 mode => 2, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
723 ]}, $sid); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
724 |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
725 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
|
726 }; |
1303 | 727 $f->{continuation} = sub { |
728 $c->new_stream({ continuation => 1, body_more => 1, headers => [ | |
729 { name => ':status', value => '200', mode => 0 }, | |
730 ]}, $sid); | |
731 $c->h2_continue($sid, { continuation => 1, headers => [ | |
732 { name => 'content-type', value => 'application/grpc', | |
733 mode => 1, huff => 1 }, | |
734 ]}); | |
735 $c->h2_continue($sid, { headers => [ | |
736 # an empty CONTINUATION frame is legitimate | |
737 ]}); | |
738 $c->h2_body('Hello world', { body_more => 1 }); | |
739 $c->new_stream({ continuation => 1, headers => [ | |
740 { name => 'grpc-status', value => '0', | |
741 mode => 2, huff => 1 }, | |
742 ]}, $sid); | |
743 $c->h2_continue($sid, { headers => [ | |
744 { name => 'grpc-message', value => '', | |
745 mode => 2, huff => 1 }, | |
746 ]}); | |
747 | |
748 return $s->read(all => [{ fin => 1 }]); | |
749 }; | |
750 $f->{field_len} = sub { | |
751 my ($len) = @_; | |
752 $c->new_stream({ continuation => [map {2**14} (0..$len/2**13)], | |
753 body_more => 1, headers => [ | |
754 { name => ':status', value => '200', mode => 0 }, | |
755 { name => 'content-type', value => 'application/grpc', | |
756 mode => 1, huff => 1 }, | |
757 { name => 'x' x $len, value => 'y' x $len, mode => 6 }, | |
758 ]}, $sid); | |
759 $c->h2_body('Hello world', { body_more => 1 }); | |
760 $c->new_stream({ headers => [ | |
761 { name => 'grpc-status', value => '0', | |
762 mode => 2, huff => 1 }, | |
763 { name => 'grpc-message', value => '', | |
764 mode => 2, huff => 1 }, | |
765 ]}, $sid); | |
766 | |
767 return $s->read(all => [{ fin => 1 }]); | |
768 }; | |
1564
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
769 $f->{discard} = sub { |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
770 my (%extra) = @_; |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
771 $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
|
772 { name => ':status', value => '200', |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
773 mode => $extra{mode} || 0 }, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
774 { name => 'content-type', value => 'application/grpc', |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
775 mode => $extra{mode} || 1, huff => 1 }, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
776 { name => 'x-connection', value => $n, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
777 mode => 2, huff => 1 }, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
778 ]}, $sid); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
779 $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
|
780 body_padding => $extra{body_padding} }); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
781 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
782 # 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
|
783 |
1623
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
784 $c->start_chain(); |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
785 $c->new_stream({ headers => [ |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
786 { 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
|
787 ]}, $sid); |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
788 $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
|
789 $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
|
790 $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
|
791 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
|
792 $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
|
793 $c->send_chain(); |
1564
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
794 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
795 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
|
796 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
|
797 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
|
798 }; |
1303 | 799 return $f; |
800 } | |
801 | |
802 sub log2i { Test::Nginx::log_core('|| <<', @_); } | |
803 sub log2o { Test::Nginx::log_core('|| >>', @_); } | |
804 sub log2c { Test::Nginx::log_core('||', @_); } | |
805 | |
806 ############################################################################### |