Mercurial > hg > nginx-tests
annotate grpc.t @ 1857:da3889ba0b96
Tests: removed unneeded require from proxy_ssl_keepalive.t.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 18 May 2023 18:07:01 +0300 |
parents | b27bcded6449 |
children | 236d038dc04a |
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/) |
1715
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
27 ->has(qw/upstream_keepalive/)->plan(146); |
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 |
1700
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
249 # upstream keepalive - GOAWAY, current request aborted |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
250 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
251 $f->{http_start}('/KeepAlive'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
252 $f->{data}('Hello'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
253 $frames = $f->{http_end}(); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
254 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
255 ok($c = $frame->{headers}{'x-connection'}, 'keepalive 4 - connection'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
256 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
257 $f->{http_start}('/KeepAlive', reuse => 1); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
258 $f->{goaway}(0, 0, 5); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
259 $f->{data}('Hello'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
260 $frames = $f->{http_end}(); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
261 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
262 is($frame->{headers}{':status'}, 502, 'keepalive 4 - GOAWAY aborted request'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
263 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
264 $f->{http_start}('/KeepAlive'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
265 $f->{data}('Hello'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
266 $frames = $f->{http_end}(); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
267 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
268 cmp_ok($frame->{headers}{'x-connection'}, '>', $c, 'keepalive 4 - closed'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
269 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
270 undef $f; |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
271 $f = grpc(); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
272 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
273 # upstream keepalive - disabled with a higher GOAWAY Last-Stream-ID |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
274 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
275 $f->{http_start}('/KeepAlive'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
276 $f->{goaway}(0, 3, 5); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
277 $f->{data}('Hello'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
278 $frames = $f->{http_end}(); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
279 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
280 ok($c = $frame->{headers}{'x-connection'}, 'keepalive 5 - GOAWAY next stream'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
281 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
282 $f->{http_start}('/KeepAlive'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
283 $f->{data}('Hello'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
284 $frames = $f->{http_end}(); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
285 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
286 cmp_ok($frame->{headers}{'x-connection'}, '>', $c, 'keepalive 5 - closed'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
287 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
288 undef $f; |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
289 $f = grpc(); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
290 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
291 # upstream keepalive - GOAWAY in grpc filter, current stream aborted |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
292 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
293 $f->{http_start}('/KeepAlive'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
294 $f->{data}('Hello'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
295 $frames = $f->{http_end}(grpc_filter_goaway => [0, 0, 5]); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
296 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
297 ok($c = $frame->{headers}{'x-connection'}, 'keepalive 6 - connection'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
298 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
299 ok($frame, 'keepalive 6 - grpc filter GOAWAY aborted stream'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
300 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
301 $f->{http_start}('/KeepAlive'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
302 $f->{data}('Hello'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
303 $frames = $f->{http_end}(); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
304 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
305 cmp_ok($frame->{headers}{'x-connection'}, '>', $c, 'keepalive 6 - closed'); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
306 |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
307 undef $f; |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
308 $f = grpc(); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
309 |
1303 | 310 # various header compression formats |
311 | |
312 $f->{http_start}('/SayHello'); | |
313 $f->{data}('Hello'); | |
314 $frames = $f->{http_end}(mode => 3); | |
315 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
316 is($frame->{headers}{':status'}, '200', 'without indexing'); | |
317 is($frame->{headers}{'content-type'}, 'application/grpc', | |
318 'without indexing 2'); | |
319 | |
320 $f->{http_start}('/SayHello'); | |
321 $f->{data}('Hello'); | |
322 $frames = $f->{http_end}(mode => 4); | |
323 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
324 is($frame->{headers}{':status'}, '200', 'without indexing new'); | |
325 is($frame->{headers}{'content-type'}, 'application/grpc', | |
326 'without indexing new 2'); | |
327 | |
328 $f->{http_start}('/SayHello'); | |
329 $f->{data}('Hello'); | |
330 $frames = $f->{http_end}(mode => 5); | |
331 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
332 is($frame->{headers}{':status'}, '200', 'never indexed'); | |
333 is($frame->{headers}{'content-type'}, 'application/grpc', | |
334 'never indexed 2'); | |
335 | |
336 $f->{http_start}('/SayHello'); | |
337 $f->{data}('Hello'); | |
338 $frames = $f->{http_end}(mode => 6); | |
339 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
340 is($frame->{headers}{':status'}, '200', 'never indexed new'); | |
341 is($frame->{headers}{'content-type'}, 'application/grpc', | |
342 'never indexed new 2'); | |
343 | |
344 # padding & priority | |
345 | |
346 $f->{http_start}('/SayHello'); | |
347 $f->{data}('Hello'); | |
348 $frames = $f->{http_end}(padding => 7); | |
349 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
350 is($frame->{headers}{':status'}, '200', 'padding'); | |
351 | |
352 $f->{http_start}('/SayHello'); | |
353 $f->{data}('Hello'); | |
354 $frames = $f->{http_end}(prio => 137, dep => 0x01020304); | |
355 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
356 is($frame->{headers}{':status'}, '200', 'priority'); | |
357 | |
358 $f->{http_start}('/SayHello'); | |
359 $f->{data}('Hello'); | |
360 $frames = $f->{http_end}(padding => 7, prio => 137, dep => 0x01020304); | |
361 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
362 is($frame->{headers}{':status'}, '200', 'padding priority'); | |
363 | |
364 SKIP: { | |
365 skip 'long test', 1 unless $ENV{TEST_NGINX_UNSAFE}; | |
366 | |
367 $f->{http_start}('/SaySplit'); | |
368 $f->{data}('Hello'); | |
369 $frames = $f->{http_end}(padding => 7, prio => 137, dep => 0x01020304, | |
370 split => [(map{1}(1..20)), 30], split_delay => 0.1); | |
371 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
372 is($frame->{headers}{':status'}, '200', 'padding priority split'); | |
373 | |
374 } | |
375 | |
376 # grpc error, no empty data frame expected | |
377 | |
378 $f->{http_start}('/SayHello'); | |
379 $f->{data}('Hello'); | |
380 $frames = $f->{http_err}(); | |
381 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
382 is($frame->{flags}, 5, 'grpc error - HEADERS flags'); | |
383 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
384 ok(!$frame, 'grpc error - no DATA frame'); | |
385 | |
1583
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
386 # 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
|
387 |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
388 $f->{http_start}('/SayHello'); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
389 $f->{data}('Hello'); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
390 $frames = $f->{http_err2}(cl => 42); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
391 ($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
|
392 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
|
393 |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
394 $f->{http_start}('/SayHello'); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
395 $f->{data}('Hello'); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
396 $frames = $f->{http_err2}(cl => 8); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
397 ($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
|
398 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
|
399 |
1303 | 400 # continuation from backend, expect parts assembled |
401 | |
402 $f->{http_start}('/SayHello'); | |
403 $f->{data}('Hello'); | |
404 $frames = $f->{continuation}(); | |
405 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
406 is($frame->{flags}, 4, 'continuation - HEADERS flags'); | |
407 is($frame->{headers}{':status'}, '200', 'continuation - status'); | |
408 is($frame->{headers}{'content-type'}, 'application/grpc', | |
409 'continuation - content type'); | |
410 | |
411 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
412 is($frame->{data}, 'Hello world', 'continuation - DATA'); | |
413 is($frame->{length}, 11, 'continuation - DATA length'); | |
414 is($frame->{flags}, 0, 'continuation - DATA flags'); | |
415 | |
416 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
417 is($frame->{flags}, 5, 'continuation - trailers flags'); | |
418 is($frame->{headers}{'grpc-message'}, '', 'continuation - trailers message'); | |
419 is($frame->{headers}{'grpc-status'}, '0', 'continuation - trailers status'); | |
420 | |
421 # continuation from backend, header split | |
422 | |
423 $f->{http_start}('/SayHello'); | |
424 $f->{data}('Hello'); | |
425 $frames = $f->{http_end}(mode => 6, continuation => [map { 1 } (1 .. 42)]); | |
426 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
427 is($frame->{headers}{':status'}, '200', 'continuation - header split'); | |
428 | |
429 # continuation to backend | |
430 | |
431 $frames = $f->{http_start}('/LongHeader?h=' . ('Z' x 31337)); | |
432 @$frames = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames; | |
433 is(@$frames, 4, 'continuation - frames'); | |
434 | |
435 $frame = shift @$frames; | |
436 is($frame->{type}, 'HEADERS', 'continuation - HEADERS'); | |
437 is($frame->{length}, 16384, 'continuation - HEADERS length'); | |
438 is($frame->{flags}, 1, 'continuation - HEADERS flags'); | |
439 ok($frame->{sid}, 'continuation - HEADERS sid'); | |
440 | |
441 $frame = shift @$frames; | |
442 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION'); | |
443 is($frame->{length}, 16384, 'continuation - CONTINUATION length'); | |
444 is($frame->{flags}, 0, 'continuation - CONTINUATION flags'); | |
445 ok($frame->{sid}, 'continuation - CONTINUATION sid'); | |
446 | |
447 $frame = shift @$frames; | |
448 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION 2'); | |
449 is($frame->{length}, 16384, 'continuation - CONTINUATION 2 length'); | |
450 is($frame->{flags}, 0, 'continuation - CONTINUATION 2 flags'); | |
451 | |
452 $frame = shift @$frames; | |
453 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION n'); | |
454 cmp_ok($frame->{length}, '<', 16384, 'continuation - CONTINUATION n length'); | |
455 is($frame->{flags}, 4, 'continuation - CONTINUATION n flags'); | |
456 is($frame->{headers}{':path'}, '/LongHeader?h=' . 'Z' x 31337, | |
457 'continuation - path'); | |
458 is($frame->{headers}{'x-longheader'}, 'Z' x 31337, 'continuation - header'); | |
459 | |
460 $f->{http_end}(); | |
461 | |
462 # long header field | |
463 | |
464 $f->{http_start}('/LongField'); | |
465 $f->{data}('Hello'); | |
466 $frames = $f->{field_len}(2**7); | |
467 ($frame) = grep { $_->{flags} & 0x4 } @$frames; | |
468 is($frame->{headers}{'x' x 2**7}, 'y' x 2**7, 'long header field 1'); | |
469 | |
470 $f->{http_start}('/LongField'); | |
471 $f->{data}('Hello'); | |
472 $frames = $f->{field_len}(2**8); | |
473 ($frame) = grep { $_->{flags} & 0x4 } @$frames; | |
474 is($frame->{headers}{'x' x 2**8}, 'y' x 2**8, 'long header field 2'); | |
475 | |
476 $f->{http_start}('/LongField'); | |
477 $f->{data}('Hello'); | |
478 $frames = $f->{field_len}(2**15); | |
479 ($frame) = grep { $_->{flags} & 0x4 } @$frames; | |
480 is($frame->{headers}{'x' x 2**15}, 'y' x 2**15, 'long header field 3'); | |
481 | |
1676
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
482 # Intermediary Encapsulation Attacks, malformed header fields |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
483 |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
484 $f->{http_start}('/'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
485 $f->{data}('Hello'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
486 $frames = $f->{field_bad}(n => 'n:n'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
487 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
488 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
|
489 |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
490 $f->{http_start}('/'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
491 $f->{data}('Hello'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
492 $frames = $f->{field_bad}(n => 'NN'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
493 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
494 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
|
495 |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
496 $f->{http_start}('/'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
497 $f->{data}('Hello'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
498 $frames = $f->{field_bad}(n => "n\nn"); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
499 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
500 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
|
501 |
1715
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
502 TODO: { |
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
503 local $TODO = 'not yet' unless $t->has_version('1.21.1'); |
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
504 |
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
505 $f->{http_start}('/'); |
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
506 $f->{data}('Hello'); |
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
507 $frames = $f->{field_bad}(n => "n n"); |
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
508 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
509 is($frame->{headers}{':status'}, 502, 'invalid header name space'); |
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
510 |
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
511 } |
3604ef83c1aa
Tests: added header name tests with forbidden characters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1707
diff
changeset
|
512 |
1676
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
513 $f->{http_start}('/'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
514 $f->{data}('Hello'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
515 $frames = $f->{field_bad}(v => "v\nv"); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
516 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
517 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
|
518 |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
519 # invalid HPACK index |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
520 |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
521 $f->{http_start}('/'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
522 $f->{data}('Hello'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
523 $frames = $f->{field_bad}('m' => 0); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
524 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
525 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
|
526 |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
527 $f->{http_start}('/'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
528 $f->{data}('Hello'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
529 $frames = $f->{field_bad}('m' => 1); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
530 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
531 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
|
532 |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
533 $f->{http_start}('/'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
534 $f->{data}('Hello'); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
535 $frames = $f->{field_bad}('m' => 3); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
536 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
537 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
|
538 |
1303 | 539 # flow control |
540 | |
541 $f->{http_start}('/FlowControl'); | |
542 $frames = $f->{data_len}(('Hello' x 13000) . ('x' x 550), 65535); | |
543 my $sum = eval join '+', map { $_->{type} eq "DATA" && $_->{length} } @$frames; | |
544 is($sum, 65535, 'flow control - iws length'); | |
545 | |
546 $f->{update}(10); | |
547 $f->{update_sid}(10); | |
548 | |
549 $frames = $f->{data_len}(undef, 10); | |
550 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
551 is($frame->{length}, 10, 'flow control - update length'); | |
552 is($frame->{flags}, 0, 'flow control - update flags'); | |
553 | |
554 $f->{update_sid}(10); | |
555 $f->{update}(10); | |
556 | |
557 $frames = $f->{data_len}(undef, 5); | |
558 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
559 is($frame->{length}, 5, 'flow control - rest length'); | |
560 is($frame->{flags}, 1, 'flow control - rest flags'); | |
561 | |
562 $f->{http_end}(); | |
563 | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
564 # preserve output |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
565 |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
566 $f->{http_start}('/Preserve'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
567 $f->{data}('Hello'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
568 $frames = $f->{http_pres}(); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
569 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
570 is($frame->{flags}, 4, 'preserve - HEADERS'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
571 |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
572 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
|
573 $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
|
574 is($sum, 20480, 'preserve - DATA'); |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
575 |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
576 (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
|
577 is($frame->{flags}, 5, 'preserve - trailers'); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
578 |
1303 | 579 # DATA padding |
580 | |
581 $f->{http_start}('/SayPadding'); | |
582 $f->{data}('Hello'); | |
583 $frames = $f->{http_end}(body_padding => 42); | |
584 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
1362
6874b32dc3d2
Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1321
diff
changeset
|
585 is($frame->{data}, 'Hello world', 'DATA padding'); |
6874b32dc3d2
Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1321
diff
changeset
|
586 is($frame->{length}, 11, 'DATA padding - length'); |
6874b32dc3d2
Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1321
diff
changeset
|
587 is($frame->{flags}, 0, 'DATA padding - flags'); |
1303 | 588 |
1664
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
589 # 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
|
590 |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
591 $f->{http_start}('/SayPadding'); |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
592 $f->{data}('Hello'); |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
593 $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
|
594 ($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
|
595 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
|
596 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
|
597 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
|
598 |
1303 | 599 # :authority inheritance |
600 | |
601 $frames = $f->{http_start}('/SayHello?if=1'); | |
602 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
603 is($frame->{headers}{':authority'}, "127.0.0.1:$p", 'authority in if'); | |
604 $f->{data}('Hello'); | |
605 $f->{http_end}(); | |
606 | |
607 # misc tests | |
608 | |
609 $frames = $f->{http_start}('/SetHost'); | |
610 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
611 ok(!$frame->{headers}{':authority'}, 'set host - authority'); | |
612 is($frame->{headers}{'host'}, 'custom', 'set host - host'); | |
613 $f->{data}('Hello'); | |
614 $f->{http_end}(); | |
615 | |
616 $frames = $f->{http_start}('/SetArgs?f'); | |
617 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
618 is($frame->{headers}{':path'}, '/SetArgs', 'set args'); | |
619 $f->{data}('Hello'); | |
620 $f->{http_end}(); | |
621 | |
622 $frames = $f->{http_start}('/SetArgs?c=1'); | |
623 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
624 is($frame->{headers}{':path'}, '/SetArgs?1', 'set args len'); | |
625 $f->{data}('Hello'); | |
626 $f->{http_end}(); | |
627 | |
628 $frames = $f->{http_start}('/'); | |
629 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
630 is($frame->{headers}{':path'}, '/', 'root index'); | |
631 $f->{data}('Hello'); | |
632 $f->{http_end}(); | |
633 | |
634 $frames = $f->{http_start}('/', method => 'GET'); | |
635 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
636 is($frame->{headers}{':method'}, 'GET', 'method get'); | |
637 $f->{data}('Hello'); | |
638 $f->{http_end}(); | |
639 | |
640 $frames = $f->{http_start}('/', method => 'HEAD'); | |
641 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
642 is($frame->{headers}{':method'}, 'HEAD', 'method head'); | |
643 $f->{data}('Hello'); | |
644 $f->{http_end}(); | |
645 | |
1564
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
646 # 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
|
647 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
648 $f->{http_start}('/Discard_WU'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
649 $frames = $f->{discard}(); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
650 (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
|
651 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
|
652 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
653 # 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
|
654 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
655 $f->{http_start}('/Discard_NE'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
656 $frames = $f->{discard}(); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
657 (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
|
658 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
|
659 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
660 # 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
|
661 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
662 $f->{http_start}('/Discard_NE3'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
663 $frames = $f->{discard}(); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
664 (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
|
665 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
|
666 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
667 # 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
|
668 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
669 $f->{http_start}('/Discard_CNL'); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
670 $frames = $f->{discard}(); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
671 (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
|
672 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
|
673 |
1631
62a1667f60f8
Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1624
diff
changeset
|
674 undef $f; |
62a1667f60f8
Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1624
diff
changeset
|
675 $f = grpc(); |
62a1667f60f8
Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1624
diff
changeset
|
676 |
1624
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
677 # 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
|
678 # 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
|
679 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
680 $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
|
681 $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
|
682 $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
|
683 ($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
|
684 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
|
685 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
686 $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
|
687 ($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
|
688 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
|
689 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
690 undef $f; |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
691 $f = grpc(); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
692 |
1303 | 693 ############################################################################### |
694 | |
695 sub grpc { | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
696 my ($server, $client, $f, $s, $c, $sid, $csid, $uri); |
1303 | 697 my $n = 0; |
698 | |
699 $server = IO::Socket::INET->new( | |
700 Proto => 'tcp', | |
701 LocalHost => '127.0.0.1', | |
702 LocalPort => $p, | |
703 Listen => 5, | |
704 Reuse => 1 | |
705 ) | |
706 or die "Can't create listening socket: $!\n"; | |
707 | |
708 $f->{http_start} = sub { | |
709 ($uri, my %extra) = @_; | |
710 my $body_more = 1 if $uri !~ /LongHeader/; | |
711 my $meth = $extra{method} || 'POST'; | |
712 $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
|
713 $csid = $s->new_stream({ body_more => $body_more, headers => [ |
1303 | 714 { name => ':method', value => $meth, mode => !!$meth }, |
715 { name => ':scheme', value => 'http', mode => 0 }, | |
716 { name => ':path', value => $uri, }, | |
717 { name => ':authority', value => 'localhost' }, | |
718 { name => 'content-type', value => 'application/grpc' }, | |
719 { name => 'te', value => 'trailers', mode => 2 }]}); | |
720 | |
721 if (!$extra{reuse}) { | |
1705
99a9b8b50f21
Tests: fixed grpc.t TODO hang on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1700
diff
changeset
|
722 if (IO::Select->new($server)->can_read(5)) { |
99a9b8b50f21
Tests: fixed grpc.t TODO hang on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1700
diff
changeset
|
723 $client = $server->accept(); |
1321
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
724 |
1705
99a9b8b50f21
Tests: fixed grpc.t TODO hang on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1700
diff
changeset
|
725 } else { |
99a9b8b50f21
Tests: fixed grpc.t TODO hang on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1700
diff
changeset
|
726 log_in("timeout"); |
1700
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
727 # connection could be unexpectedly reused |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
728 goto reused if $client; |
1321
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
729 return undef; |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
730 } |
351b95be742b
Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1319
diff
changeset
|
731 |
1303 | 732 log2c("(new connection $client)"); |
733 $n++; | |
734 | |
735 $client->sysread(my $buf, 24) == 24 or return; # preface | |
736 | |
737 $c = Test::Nginx::HTTP2->new(1, socket => $client, | |
738 pure => 1, preface => "") or return; | |
739 } | |
740 | |
1700
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
741 reused: |
1303 | 742 my $frames = $c->read(all => [{ fin => 4 }]); |
743 | |
744 if (!$extra{reuse}) { | |
745 $c->h2_settings(0); | |
746 $c->h2_settings(1); | |
747 } | |
748 | |
749 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
750 $sid = $frame->{sid}; | |
751 return $frames; | |
752 }; | |
753 $f->{data} = sub { | |
754 my ($body, %extra) = @_; | |
755 $s->h2_body($body, { %extra }); | |
756 return $c->read(all => [{ sid => $sid, | |
757 length => length($body) }]); | |
758 }; | |
759 $f->{data_len} = sub { | |
760 my ($body, $len) = @_; | |
761 $s->h2_body($body) if defined $body; | |
762 return $c->read(all => [{ sid => $sid, length => $len }]); | |
763 }; | |
764 $f->{update} = sub { | |
765 $c->h2_window(shift); | |
766 }; | |
767 $f->{update_sid} = sub { | |
768 $c->h2_window(shift, $sid); | |
769 }; | |
1370
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
770 $f->{settings} = sub { |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
771 $c->h2_settings(@_); |
23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1362
diff
changeset
|
772 }; |
1700
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
773 $f->{goaway} = sub { |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
774 $c->h2_goaway(@_); |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
775 }; |
1303 | 776 $f->{http_end} = sub { |
777 my (%extra) = @_; | |
1664
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
778 my $h = [ |
1303 | 779 { name => ':status', value => '200', |
780 mode => $extra{mode} || 0 }, | |
781 { name => 'content-type', value => 'application/grpc', | |
782 mode => $extra{mode} || 1, huff => 1 }, | |
783 { 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
|
784 mode => 2, huff => 1 }]; |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
785 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
|
786 if $extra{cl}; |
0fae67763be5
Tests: added grpc tests with DATA padding and Content-Length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1653
diff
changeset
|
787 $c->new_stream({ body_more => 1, headers => $h, %extra }, $sid); |
1303 | 788 $c->h2_body('Hello world', { body_more => 1, |
789 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
|
790 $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
|
791 if $extra{grpc_filter_settings}; |
1700
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
792 $c->h2_goaway(@{$extra{grpc_filter_goaway}}) |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
793 if $extra{grpc_filter_goaway}; |
1303 | 794 $c->new_stream({ headers => [ |
795 { name => 'grpc-status', value => '0', | |
796 mode => 2, huff => 1 }, | |
797 { name => 'grpc-message', value => '', | |
798 mode => 2, huff => 1 }, | |
799 ]}, $sid); | |
800 | |
1700
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
801 return $s->read(all => [{ type => 'RST_STREAM' }]) |
c903c0a3f302
Tests: added grpc GOAWAY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1699
diff
changeset
|
802 if $extra{grpc_filter_goaway}; |
1303 | 803 return $s->read(all => [{ fin => 1 }]); |
804 }; | |
1318
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
805 $f->{http_pres} = sub { |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
806 my (%extra) = @_; |
1319
3b30e97acdcb
Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1318
diff
changeset
|
807 $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
|
808 $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
|
809 { name => ':status', value => '200', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
810 mode => $extra{mode} || 0 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
811 { name => 'content-type', value => 'application/grpc', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
812 mode => $extra{mode} || 1, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
813 { name => 'x-connection', value => $n, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
814 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
815 ]}, $sid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
816 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
|
817 $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
|
818 body_more => 1, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
819 body_padding => $extra{body_padding} }); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
820 $c->h2_ping("PING"); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
821 } |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
822 # reopen window |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
823 $s->h2_window(2**24); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
824 $s->h2_window(2**24, $csid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
825 $c->new_stream({ headers => [ |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
826 { name => 'grpc-status', value => '0', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
827 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
828 { name => 'grpc-message', value => '', |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
829 mode => 2, huff => 1 }, |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
830 ]}, $sid); |
6de2a27af2d3
Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1312
diff
changeset
|
831 |
1319
3b30e97acdcb
Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1318
diff
changeset
|
832 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
|
833 }; |
1303 | 834 $f->{http_err} = sub { |
835 $c->new_stream({ headers => [ | |
836 { name => ':status', value => '200', mode => 0 }, | |
837 { name => 'content-type', value => 'application/grpc', | |
838 mode => 1, huff => 1 }, | |
839 { name => 'grpc-status', value => '12', | |
840 mode => 2, huff => 1 }, | |
841 { name => 'grpc-message', value => 'unknown service', | |
842 mode => 2, huff => 1 }, | |
843 ]}, $sid); | |
844 | |
845 return $s->read(all => [{ fin => 1 }]); | |
846 }; | |
1624
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
847 $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
|
848 $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
|
849 $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
|
850 { 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
|
851 { 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
|
852 { 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
|
853 { 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
|
854 mode => 2 }, |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
855 ]}, $sid); |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
856 $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
|
857 $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
|
858 |
81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1623
diff
changeset
|
859 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
|
860 }; |
1583
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
861 $f->{http_err2} = sub { |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
862 my %extra = @_; |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
863 $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
|
864 { name => ':status', value => '200', mode => 0 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
865 { name => 'content-type', value => 'application/grpc', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
866 mode => 1, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
867 { name => 'content-length', value => $extra{cl}, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
868 mode => 1, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
869 ]}, $sid); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
870 $c->h2_body('Hello world', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
871 { body_more => 1, body_split => [5] }); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
872 $c->new_stream({ headers => [ |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
873 { name => 'grpc-status', value => '0', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
874 mode => 2, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
875 { name => 'grpc-message', value => '', |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
876 mode => 2, huff => 1 }, |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
877 ]}, $sid); |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
878 |
8aede7babd9a
Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1564
diff
changeset
|
879 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
|
880 }; |
1303 | 881 $f->{continuation} = sub { |
882 $c->new_stream({ continuation => 1, body_more => 1, headers => [ | |
883 { name => ':status', value => '200', mode => 0 }, | |
884 ]}, $sid); | |
885 $c->h2_continue($sid, { continuation => 1, headers => [ | |
886 { name => 'content-type', value => 'application/grpc', | |
887 mode => 1, huff => 1 }, | |
888 ]}); | |
889 $c->h2_continue($sid, { headers => [ | |
890 # an empty CONTINUATION frame is legitimate | |
891 ]}); | |
892 $c->h2_body('Hello world', { body_more => 1 }); | |
893 $c->new_stream({ continuation => 1, headers => [ | |
894 { name => 'grpc-status', value => '0', | |
895 mode => 2, huff => 1 }, | |
896 ]}, $sid); | |
897 $c->h2_continue($sid, { headers => [ | |
898 { name => 'grpc-message', value => '', | |
899 mode => 2, huff => 1 }, | |
900 ]}); | |
901 | |
902 return $s->read(all => [{ fin => 1 }]); | |
903 }; | |
904 $f->{field_len} = sub { | |
905 my ($len) = @_; | |
906 $c->new_stream({ continuation => [map {2**14} (0..$len/2**13)], | |
907 body_more => 1, headers => [ | |
908 { name => ':status', value => '200', mode => 0 }, | |
909 { name => 'content-type', value => 'application/grpc', | |
910 mode => 1, huff => 1 }, | |
911 { name => 'x' x $len, value => 'y' x $len, mode => 6 }, | |
912 ]}, $sid); | |
913 $c->h2_body('Hello world', { body_more => 1 }); | |
914 $c->new_stream({ headers => [ | |
915 { name => 'grpc-status', value => '0', | |
916 mode => 2, huff => 1 }, | |
917 { name => 'grpc-message', value => '', | |
918 mode => 2, huff => 1 }, | |
919 ]}, $sid); | |
920 | |
921 return $s->read(all => [{ fin => 1 }]); | |
922 }; | |
1676
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
923 $f->{field_bad} = sub { |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
924 my (%extra) = @_; |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
925 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
|
926 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
|
927 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
|
928 $c->new_stream({ headers => [ |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
929 { name => ':status', value => '200' }, |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
930 { name => $n, value => $v, mode => $m }, |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
931 ]}, $sid); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
932 |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
933 return $s->read(all => [{ fin => 1 }]); |
816d6ceefe50
Tests: added grpc tests with malformed headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1664
diff
changeset
|
934 }; |
1564
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
935 $f->{discard} = sub { |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
936 my (%extra) = @_; |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
937 $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
|
938 { name => ':status', value => '200', |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
939 mode => $extra{mode} || 0 }, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
940 { name => 'content-type', value => 'application/grpc', |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
941 mode => $extra{mode} || 1, huff => 1 }, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
942 { name => 'x-connection', value => $n, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
943 mode => 2, huff => 1 }, |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
944 ]}, $sid); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
945 $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
|
946 body_padding => $extra{body_padding} }); |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
947 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
948 # 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
|
949 |
1623
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
950 $c->start_chain(); |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
951 $c->new_stream({ headers => [ |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
952 { 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
|
953 ]}, $sid); |
3fe652bc9dae
Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1622
diff
changeset
|
954 $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
|
955 $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
|
956 $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
|
957 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
|
958 $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
|
959 $c->send_chain(); |
1564
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
960 |
fe938b5daf80
Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
961 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
|
962 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
|
963 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
|
964 }; |
1303 | 965 return $f; |
966 } | |
967 | |
968 sub log2i { Test::Nginx::log_core('|| <<', @_); } | |
969 sub log2o { Test::Nginx::log_core('|| >>', @_); } | |
970 sub log2c { Test::Nginx::log_core('||', @_); } | |
971 | |
972 ############################################################################### |