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