Mercurial > hg > nginx-tests
annotate grpc.t @ 1381:97c8280de681
Tests: removed TODO and try_run() checks for legacy versions.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 08 Oct 2018 15:30:39 +0300 |
parents | 23e407a72fe9 |
children | 2c0955286894 |
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/) |
1381
97c8280de681
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1370
diff
changeset
|
27 ->has(qw/upstream_keepalive/)->plan(105); |
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; | |
53 | |
54 location / { | |
55 grpc_pass grpc://127.0.0.1:8081; | |
56 | |
57 if ($arg_if) { | |
58 # nothing | |
59 } | |
60 | |
61 limit_except GET { | |
62 # nothing | |
63 } | |
64 } | |
65 | |
66 location /KeepAlive { | |
67 grpc_pass u; | |
68 } | |
69 | |
70 location /LongHeader { | |
71 grpc_pass 127.0.0.1:8081; | |
72 grpc_set_header X-LongHeader $arg_h; | |
73 } | |
74 | |
75 location /LongField { | |
76 grpc_pass 127.0.0.1:8081; | |
77 grpc_buffer_size 65k; | |
78 } | |
79 | |
80 location /SetHost { | |
81 grpc_pass 127.0.0.1:8081; | |
82 grpc_set_header Host custom; | |
83 } | |
84 | |
85 location /SetArgs { | |
86 grpc_pass 127.0.0.1:8081; | |
87 set $args $arg_c; | |
88 } | |
89 } | |
90 } | |
91 | |
92 EOF | |
93 | |
1381
97c8280de681
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1370
diff
changeset
|
94 $t->run(); |
1303 | 95 |
96 ############################################################################### | |
97 | |
98 my $p = port(8081); | |
99 my $f = grpc(); | |
100 | |
101 my $frames = $f->{http_start}('/SayHello'); | |
102 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
103 is($frame->{flags}, 4, 'request - HEADERS flags'); | |
104 ok((my $sid = $frame->{sid}) % 2, 'request - HEADERS sid odd'); | |
105 is($frame->{headers}{':method'}, 'POST', 'request - method'); | |
106 is($frame->{headers}{':scheme'}, 'http', 'request - scheme'); | |
107 is($frame->{headers}{':path'}, '/SayHello', 'request - path'); | |
108 is($frame->{headers}{':authority'}, "127.0.0.1:$p", 'request - authority'); | |
109 is($frame->{headers}{'content-type'}, 'application/grpc', | |
110 'request - content type'); | |
111 is($frame->{headers}{te}, 'trailers', 'request - te'); | |
112 | |
113 $frames = $f->{data}('Hello'); | |
114 ($frame) = grep { $_->{type} eq "SETTINGS" } @$frames; | |
115 is($frame->{flags}, 1, 'request - SETTINGS ack'); | |
116 is($frame->{sid}, 0, 'request - SETTINGS sid'); | |
117 is($frame->{length}, 0, 'request - SETTINGS length'); | |
118 | |
119 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
120 is($frame->{data}, 'Hello', 'request - DATA'); | |
121 is($frame->{length}, 5, 'request - DATA length'); | |
122 is($frame->{flags}, 1, 'request - DATA flags'); | |
123 is($frame->{sid}, $sid, 'request - DATA sid match'); | |
124 | |
125 $frames = $f->{http_end}(); | |
126 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
127 is($frame->{flags}, 4, 'response - HEADERS flags'); | |
128 is($frame->{sid}, 1, 'response - HEADERS sid'); | |
129 is($frame->{headers}{':status'}, '200', 'response - status'); | |
130 is($frame->{headers}{'content-type'}, 'application/grpc', | |
131 'response - content type'); | |
132 ok($frame->{headers}{server}, 'response - server'); | |
133 ok($frame->{headers}{date}, 'response - date'); | |
134 ok(my $c = $frame->{headers}{'x-connection'}, 'response - connection'); | |
135 | |
136 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
137 is($frame->{data}, 'Hello world', 'response - DATA'); | |
138 is($frame->{length}, 11, 'response - DATA length'); | |
139 is($frame->{flags}, 0, 'response - DATA flags'); | |
140 is($frame->{sid}, 1, 'response - DATA sid'); | |
141 | |
142 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
143 is($frame->{flags}, 5, 'response - trailers flags'); | |
144 is($frame->{sid}, 1, 'response - trailers sid'); | |
145 is($frame->{headers}{'grpc-message'}, '', 'response - trailers message'); | |
146 is($frame->{headers}{'grpc-status'}, '0', 'response - trailers status'); | |
147 | |
148 # next request is on a new backend connection, no sid incremented | |
149 | |
150 $frames = $f->{http_start}('/SayHello'); | |
151 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
152 is($frame->{sid}, $sid, 'request 2 - HEADERS sid again'); | |
153 $f->{data}('Hello'); | |
154 $frames = $f->{http_end}(); | |
155 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
156 cmp_ok($frame->{headers}{'x-connection'}, '>', $c, 'response 2 - connection'); | |
157 | |
158 # upstream keepalive | |
159 | |
160 $frames = $f->{http_start}('/KeepAlive'); | |
161 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
162 is($frame->{sid}, $sid, 'keepalive - HEADERS sid'); | |
163 $f->{data}('Hello'); | |
164 $frames = $f->{http_end}(); | |
165 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
166 ok($c = $frame->{headers}{'x-connection'}, 'keepalive - connection'); | |
167 | |
168 $frames = $f->{http_start}('/KeepAlive', reuse => 1); | |
169 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
170 cmp_ok($frame->{sid}, '>', $sid, 'keepalive - HEADERS sid next'); | |
171 $f->{data}('Hello'); | |
172 $frames = $f->{http_end}(); | |
173 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
174 is($frame->{headers}{'x-connection'}, $c, 'keepalive - connection reuse'); | |
175 | |
1370
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
176 # upstream keepalive |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
177 # pending control frame ack after the response |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
178 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
179 undef $f; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
180 $f = grpc(); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
181 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
182 $frames = $f->{http_start}('/KeepAlive'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
183 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
184 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
|
185 $f->{data}('Hello'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
186 $f->{settings}(0, 1 => 4096); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
187 $frames = $f->{http_end}(); |
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 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
|
190 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
191 $frames = $f->{http_start}('/KeepAlive', reuse => 1); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
192 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
193 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
194 TODO: { |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
195 local $TODO = 'not yet' unless $t->has_version('1.15.4'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
196 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
197 ok($frame, 'upstream keepalive reused'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
198 |
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 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
201 TODO: { |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
202 todo_skip 'upstream connection failed', 2 unless $frame; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
203 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
204 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
|
205 $f->{data}('Hello'); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
206 $frames = $f->{http_end}(); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
207 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
208 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
|
209 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
210 } |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
211 |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
212 undef $f; |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
213 $f = grpc(); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
214 |
1303 | 215 # various header compression formats |
216 | |
217 $f->{http_start}('/SayHello'); | |
218 $f->{data}('Hello'); | |
219 $frames = $f->{http_end}(mode => 3); | |
220 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
221 is($frame->{headers}{':status'}, '200', 'without indexing'); | |
222 is($frame->{headers}{'content-type'}, 'application/grpc', | |
223 'without indexing 2'); | |
224 | |
225 $f->{http_start}('/SayHello'); | |
226 $f->{data}('Hello'); | |
227 $frames = $f->{http_end}(mode => 4); | |
228 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
229 is($frame->{headers}{':status'}, '200', 'without indexing new'); | |
230 is($frame->{headers}{'content-type'}, 'application/grpc', | |
231 'without indexing new 2'); | |
232 | |
233 $f->{http_start}('/SayHello'); | |
234 $f->{data}('Hello'); | |
235 $frames = $f->{http_end}(mode => 5); | |
236 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
237 is($frame->{headers}{':status'}, '200', 'never indexed'); | |
238 is($frame->{headers}{'content-type'}, 'application/grpc', | |
239 'never indexed 2'); | |
240 | |
241 $f->{http_start}('/SayHello'); | |
242 $f->{data}('Hello'); | |
243 $frames = $f->{http_end}(mode => 6); | |
244 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
245 is($frame->{headers}{':status'}, '200', 'never indexed new'); | |
246 is($frame->{headers}{'content-type'}, 'application/grpc', | |
247 'never indexed new 2'); | |
248 | |
249 # padding & priority | |
250 | |
251 $f->{http_start}('/SayHello'); | |
252 $f->{data}('Hello'); | |
253 $frames = $f->{http_end}(padding => 7); | |
254 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
255 is($frame->{headers}{':status'}, '200', 'padding'); | |
256 | |
257 $f->{http_start}('/SayHello'); | |
258 $f->{data}('Hello'); | |
259 $frames = $f->{http_end}(prio => 137, dep => 0x01020304); | |
260 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
261 is($frame->{headers}{':status'}, '200', 'priority'); | |
262 | |
263 $f->{http_start}('/SayHello'); | |
264 $f->{data}('Hello'); | |
265 $frames = $f->{http_end}(padding => 7, prio => 137, dep => 0x01020304); | |
266 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
267 is($frame->{headers}{':status'}, '200', 'padding priority'); | |
268 | |
269 SKIP: { | |
270 skip 'long test', 1 unless $ENV{TEST_NGINX_UNSAFE}; | |
271 | |
272 $f->{http_start}('/SaySplit'); | |
273 $f->{data}('Hello'); | |
274 $frames = $f->{http_end}(padding => 7, prio => 137, dep => 0x01020304, | |
275 split => [(map{1}(1..20)), 30], split_delay => 0.1); | |
276 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
277 is($frame->{headers}{':status'}, '200', 'padding priority split'); | |
278 | |
279 } | |
280 | |
281 # grpc error, no empty data frame expected | |
282 | |
283 $f->{http_start}('/SayHello'); | |
284 $f->{data}('Hello'); | |
285 $frames = $f->{http_err}(); | |
286 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
287 is($frame->{flags}, 5, 'grpc error - HEADERS flags'); | |
288 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
289 ok(!$frame, 'grpc error - no DATA frame'); | |
290 | |
291 # continuation from backend, expect parts assembled | |
292 | |
293 $f->{http_start}('/SayHello'); | |
294 $f->{data}('Hello'); | |
295 $frames = $f->{continuation}(); | |
296 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
297 is($frame->{flags}, 4, 'continuation - HEADERS flags'); | |
298 is($frame->{headers}{':status'}, '200', 'continuation - status'); | |
299 is($frame->{headers}{'content-type'}, 'application/grpc', | |
300 'continuation - content type'); | |
301 | |
302 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
303 is($frame->{data}, 'Hello world', 'continuation - DATA'); | |
304 is($frame->{length}, 11, 'continuation - DATA length'); | |
305 is($frame->{flags}, 0, 'continuation - DATA flags'); | |
306 | |
307 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
308 is($frame->{flags}, 5, 'continuation - trailers flags'); | |
309 is($frame->{headers}{'grpc-message'}, '', 'continuation - trailers message'); | |
310 is($frame->{headers}{'grpc-status'}, '0', 'continuation - trailers status'); | |
311 | |
312 # continuation from backend, header split | |
313 | |
314 $f->{http_start}('/SayHello'); | |
315 $f->{data}('Hello'); | |
316 $frames = $f->{http_end}(mode => 6, continuation => [map { 1 } (1 .. 42)]); | |
317 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
318 is($frame->{headers}{':status'}, '200', 'continuation - header split'); | |
319 | |
320 # continuation to backend | |
321 | |
322 $frames = $f->{http_start}('/LongHeader?h=' . ('Z' x 31337)); | |
323 @$frames = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames; | |
324 is(@$frames, 4, 'continuation - frames'); | |
325 | |
326 $frame = shift @$frames; | |
327 is($frame->{type}, 'HEADERS', 'continuation - HEADERS'); | |
328 is($frame->{length}, 16384, 'continuation - HEADERS length'); | |
329 is($frame->{flags}, 1, 'continuation - HEADERS flags'); | |
330 ok($frame->{sid}, 'continuation - HEADERS sid'); | |
331 | |
332 $frame = shift @$frames; | |
333 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION'); | |
334 is($frame->{length}, 16384, 'continuation - CONTINUATION length'); | |
335 is($frame->{flags}, 0, 'continuation - CONTINUATION flags'); | |
336 ok($frame->{sid}, 'continuation - CONTINUATION sid'); | |
337 | |
338 $frame = shift @$frames; | |
339 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION 2'); | |
340 is($frame->{length}, 16384, 'continuation - CONTINUATION 2 length'); | |
341 is($frame->{flags}, 0, 'continuation - CONTINUATION 2 flags'); | |
342 | |
343 $frame = shift @$frames; | |
344 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION n'); | |
345 cmp_ok($frame->{length}, '<', 16384, 'continuation - CONTINUATION n length'); | |
346 is($frame->{flags}, 4, 'continuation - CONTINUATION n flags'); | |
347 is($frame->{headers}{':path'}, '/LongHeader?h=' . 'Z' x 31337, | |
348 'continuation - path'); | |
349 is($frame->{headers}{'x-longheader'}, 'Z' x 31337, 'continuation - header'); | |
350 | |
351 $f->{http_end}(); | |
352 | |
353 # long header field | |
354 | |
355 $f->{http_start}('/LongField'); | |
356 $f->{data}('Hello'); | |
357 $frames = $f->{field_len}(2**7); | |
358 ($frame) = grep { $_->{flags} & 0x4 } @$frames; | |
359 is($frame->{headers}{'x' x 2**7}, 'y' x 2**7, 'long header field 1'); | |
360 | |
361 $f->{http_start}('/LongField'); | |
362 $f->{data}('Hello'); | |
363 $frames = $f->{field_len}(2**8); | |
364 ($frame) = grep { $_->{flags} & 0x4 } @$frames; | |
365 is($frame->{headers}{'x' x 2**8}, 'y' x 2**8, 'long header field 2'); | |
366 | |
367 $f->{http_start}('/LongField'); | |
368 $f->{data}('Hello'); | |
369 $frames = $f->{field_len}(2**15); | |
370 ($frame) = grep { $_->{flags} & 0x4 } @$frames; | |
371 is($frame->{headers}{'x' x 2**15}, 'y' x 2**15, 'long header field 3'); | |
372 | |
373 # flow control | |
374 | |
375 $f->{http_start}('/FlowControl'); | |
376 $frames = $f->{data_len}(('Hello' x 13000) . ('x' x 550), 65535); | |
377 my $sum = eval join '+', map { $_->{type} eq "DATA" && $_->{length} } @$frames; | |
378 is($sum, 65535, 'flow control - iws length'); | |
379 | |
380 $f->{update}(10); | |
381 $f->{update_sid}(10); | |
382 | |
383 $frames = $f->{data_len}(undef, 10); | |
384 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
385 is($frame->{length}, 10, 'flow control - update length'); | |
386 is($frame->{flags}, 0, 'flow control - update flags'); | |
387 | |
388 $f->{update_sid}(10); | |
389 $f->{update}(10); | |
390 | |
391 $frames = $f->{data_len}(undef, 5); | |
392 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
393 is($frame->{length}, 5, 'flow control - rest length'); | |
394 is($frame->{flags}, 1, 'flow control - rest flags'); | |
395 | |
396 $f->{http_end}(); | |
397 | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
398 # preserve output |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
399 |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
400 $f->{http_start}('/Preserve'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
401 $f->{data}('Hello'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
402 $frames = $f->{http_pres}(); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
403 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
404 is($frame->{flags}, 4, 'preserve - HEADERS'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
405 |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
406 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
|
407 $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
|
408 is($sum, 20480, 'preserve - DATA'); |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
409 |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
410 (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
|
411 is($frame->{flags}, 5, 'preserve - trailers'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
412 |
1303 | 413 # DATA padding |
414 | |
415 $f->{http_start}('/SayPadding'); | |
416 $f->{data}('Hello'); | |
417 $frames = $f->{http_end}(body_padding => 42); | |
418 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
1362
6874b32dc3d2
Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1321
diff
changeset
|
419 is($frame->{data}, 'Hello world', 'DATA padding'); |
6874b32dc3d2
Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1321
diff
changeset
|
420 is($frame->{length}, 11, 'DATA padding - length'); |
6874b32dc3d2
Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1321
diff
changeset
|
421 is($frame->{flags}, 0, 'DATA padding - flags'); |
1303 | 422 |
423 # :authority inheritance | |
424 | |
425 $frames = $f->{http_start}('/SayHello?if=1'); | |
426 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
427 is($frame->{headers}{':authority'}, "127.0.0.1:$p", 'authority in if'); | |
428 $f->{data}('Hello'); | |
429 $f->{http_end}(); | |
430 | |
431 # misc tests | |
432 | |
433 $frames = $f->{http_start}('/SetHost'); | |
434 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
435 ok(!$frame->{headers}{':authority'}, 'set host - authority'); | |
436 is($frame->{headers}{'host'}, 'custom', 'set host - host'); | |
437 $f->{data}('Hello'); | |
438 $f->{http_end}(); | |
439 | |
440 $frames = $f->{http_start}('/SetArgs?f'); | |
441 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
442 is($frame->{headers}{':path'}, '/SetArgs', 'set args'); | |
443 $f->{data}('Hello'); | |
444 $f->{http_end}(); | |
445 | |
446 $frames = $f->{http_start}('/SetArgs?c=1'); | |
447 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
448 is($frame->{headers}{':path'}, '/SetArgs?1', 'set args len'); | |
449 $f->{data}('Hello'); | |
450 $f->{http_end}(); | |
451 | |
452 $frames = $f->{http_start}('/SetArgs esc'); | |
453 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
454 is($frame->{headers}{':path'}, '/SetArgs%20esc', 'uri escape'); | |
455 $f->{data}('Hello'); | |
456 $f->{http_end}(); | |
457 | |
458 $frames = $f->{http_start}('/'); | |
459 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
460 is($frame->{headers}{':path'}, '/', 'root index'); | |
461 $f->{data}('Hello'); | |
462 $f->{http_end}(); | |
463 | |
464 $frames = $f->{http_start}('/', method => 'GET'); | |
465 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
466 is($frame->{headers}{':method'}, 'GET', 'method get'); | |
467 $f->{data}('Hello'); | |
468 $f->{http_end}(); | |
469 | |
470 $frames = $f->{http_start}('/', method => 'HEAD'); | |
471 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
472 is($frame->{headers}{':method'}, 'HEAD', 'method head'); | |
473 $f->{data}('Hello'); | |
474 $f->{http_end}(); | |
475 | |
476 ############################################################################### | |
477 | |
478 sub grpc { | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
479 my ($server, $client, $f, $s, $c, $sid, $csid, $uri); |
1303 | 480 my $n = 0; |
481 | |
482 $server = IO::Socket::INET->new( | |
483 Proto => 'tcp', | |
484 LocalHost => '127.0.0.1', | |
485 LocalPort => $p, | |
486 Listen => 5, | |
487 Reuse => 1 | |
488 ) | |
489 or die "Can't create listening socket: $!\n"; | |
490 | |
491 $f->{http_start} = sub { | |
492 ($uri, my %extra) = @_; | |
493 my $body_more = 1 if $uri !~ /LongHeader/; | |
494 my $meth = $extra{method} || 'POST'; | |
495 $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
|
496 $csid = $s->new_stream({ body_more => $body_more, headers => [ |
1303 | 497 { name => ':method', value => $meth, mode => !!$meth }, |
498 { name => ':scheme', value => 'http', mode => 0 }, | |
499 { name => ':path', value => $uri, }, | |
500 { name => ':authority', value => 'localhost' }, | |
501 { name => 'content-type', value => 'application/grpc' }, | |
502 { name => 'te', value => 'trailers', mode => 2 }]}); | |
503 | |
504 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
|
505 eval { |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
506 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
|
507 alarm(5); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
508 |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
509 $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
|
510 |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
511 alarm(0); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
512 }; |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
513 alarm(0); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
514 if ($@) { |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
515 log_in("died: $@"); |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
516 return undef; |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
517 } |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
518 |
1303 | 519 log2c("(new connection $client)"); |
520 $n++; | |
521 | |
522 $client->sysread(my $buf, 24) == 24 or return; # preface | |
523 | |
524 $c = Test::Nginx::HTTP2->new(1, socket => $client, | |
525 pure => 1, preface => "") or return; | |
526 } | |
527 | |
528 my $frames = $c->read(all => [{ fin => 4 }]); | |
529 | |
530 if (!$extra{reuse}) { | |
531 $c->h2_settings(0); | |
532 $c->h2_settings(1); | |
533 } | |
534 | |
535 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
536 $sid = $frame->{sid}; | |
537 return $frames; | |
538 }; | |
539 $f->{data} = sub { | |
540 my ($body, %extra) = @_; | |
541 $s->h2_body($body, { %extra }); | |
542 return $c->read(all => [{ sid => $sid, | |
543 length => length($body) }]); | |
544 }; | |
545 $f->{data_len} = sub { | |
546 my ($body, $len) = @_; | |
547 $s->h2_body($body) if defined $body; | |
548 return $c->read(all => [{ sid => $sid, length => $len }]); | |
549 }; | |
550 $f->{update} = sub { | |
551 $c->h2_window(shift); | |
552 }; | |
553 $f->{update_sid} = sub { | |
554 $c->h2_window(shift, $sid); | |
555 }; | |
1370
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
556 $f->{settings} = sub { |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
557 $c->h2_settings(@_); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
558 }; |
1303 | 559 $f->{http_end} = sub { |
560 my (%extra) = @_; | |
561 $c->new_stream({ body_more => 1, %extra, headers => [ | |
562 { name => ':status', value => '200', | |
563 mode => $extra{mode} || 0 }, | |
564 { name => 'content-type', value => 'application/grpc', | |
565 mode => $extra{mode} || 1, huff => 1 }, | |
566 { name => 'x-connection', value => $n, | |
567 mode => 2, huff => 1 }, | |
568 ]}, $sid); | |
569 $c->h2_body('Hello world', { body_more => 1, | |
570 body_padding => $extra{body_padding} }); | |
571 $c->new_stream({ headers => [ | |
572 { name => 'grpc-status', value => '0', | |
573 mode => 2, huff => 1 }, | |
574 { name => 'grpc-message', value => '', | |
575 mode => 2, huff => 1 }, | |
576 ]}, $sid); | |
577 | |
578 return $s->read(all => [{ fin => 1 }]); | |
579 }; | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
580 $f->{http_pres} = sub { |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
581 my (%extra) = @_; |
1319
3b30e97acdcb
Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1318
diff
changeset
|
582 $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
|
583 $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
|
584 { name => ':status', value => '200', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
585 mode => $extra{mode} || 0 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
586 { name => 'content-type', value => 'application/grpc', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
587 mode => $extra{mode} || 1, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
588 { name => 'x-connection', value => $n, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
589 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
590 ]}, $sid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
591 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
|
592 $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
|
593 body_more => 1, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
594 body_padding => $extra{body_padding} }); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
595 $c->h2_ping("PING"); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
596 } |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
597 # reopen window |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
598 $s->h2_window(2**24); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
599 $s->h2_window(2**24, $csid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
600 $c->new_stream({ headers => [ |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
601 { name => 'grpc-status', value => '0', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
602 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
603 { name => 'grpc-message', value => '', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
604 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
605 ]}, $sid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
606 |
1319
3b30e97acdcb
Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1318
diff
changeset
|
607 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
|
608 }; |
1303 | 609 $f->{http_err} = sub { |
610 $c->new_stream({ headers => [ | |
611 { name => ':status', value => '200', mode => 0 }, | |
612 { name => 'content-type', value => 'application/grpc', | |
613 mode => 1, huff => 1 }, | |
614 { name => 'grpc-status', value => '12', | |
615 mode => 2, huff => 1 }, | |
616 { name => 'grpc-message', value => 'unknown service', | |
617 mode => 2, huff => 1 }, | |
618 ]}, $sid); | |
619 | |
620 return $s->read(all => [{ fin => 1 }]); | |
621 }; | |
622 $f->{continuation} = sub { | |
623 $c->new_stream({ continuation => 1, body_more => 1, headers => [ | |
624 { name => ':status', value => '200', mode => 0 }, | |
625 ]}, $sid); | |
626 $c->h2_continue($sid, { continuation => 1, headers => [ | |
627 { name => 'content-type', value => 'application/grpc', | |
628 mode => 1, huff => 1 }, | |
629 ]}); | |
630 $c->h2_continue($sid, { headers => [ | |
631 # an empty CONTINUATION frame is legitimate | |
632 ]}); | |
633 $c->h2_body('Hello world', { body_more => 1 }); | |
634 $c->new_stream({ continuation => 1, headers => [ | |
635 { name => 'grpc-status', value => '0', | |
636 mode => 2, huff => 1 }, | |
637 ]}, $sid); | |
638 $c->h2_continue($sid, { headers => [ | |
639 { name => 'grpc-message', value => '', | |
640 mode => 2, huff => 1 }, | |
641 ]}); | |
642 | |
643 return $s->read(all => [{ fin => 1 }]); | |
644 }; | |
645 $f->{field_len} = sub { | |
646 my ($len) = @_; | |
647 $c->new_stream({ continuation => [map {2**14} (0..$len/2**13)], | |
648 body_more => 1, headers => [ | |
649 { name => ':status', value => '200', mode => 0 }, | |
650 { name => 'content-type', value => 'application/grpc', | |
651 mode => 1, huff => 1 }, | |
652 { name => 'x' x $len, value => 'y' x $len, mode => 6 }, | |
653 ]}, $sid); | |
654 $c->h2_body('Hello world', { body_more => 1 }); | |
655 $c->new_stream({ headers => [ | |
656 { name => 'grpc-status', value => '0', | |
657 mode => 2, huff => 1 }, | |
658 { name => 'grpc-message', value => '', | |
659 mode => 2, huff => 1 }, | |
660 ]}, $sid); | |
661 | |
662 return $s->read(all => [{ fin => 1 }]); | |
663 }; | |
664 return $f; | |
665 } | |
666 | |
667 sub log2i { Test::Nginx::log_core('|| <<', @_); } | |
668 sub log2o { Test::Nginx::log_core('|| >>', @_); } | |
669 sub log2c { Test::Nginx::log_core('||', @_); } | |
670 | |
671 ############################################################################### |