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