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