Mercurial > hg > nginx-tests
comparison grpc.t @ 1698:90201294e1b6
Tests: added grpc request body test with a special last buffer.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 03 Jun 2021 14:38:58 +0300 |
parents | 5ac6efbe5552 |
children | 202d8feedad1 |
comparison
equal
deleted
inserted
replaced
1697:5386f4328b90 | 1698:90201294e1b6 |
---|---|
22 | 22 |
23 select STDERR; $| = 1; | 23 select STDERR; $| = 1; |
24 select STDOUT; $| = 1; | 24 select STDOUT; $| = 1; |
25 | 25 |
26 my $t = Test::Nginx->new()->has(qw/http rewrite http_v2 grpc/) | 26 my $t = Test::Nginx->new()->has(qw/http rewrite http_v2 grpc/) |
27 ->has(qw/upstream_keepalive/)->plan(123); | 27 ->has(qw/upstream_keepalive/)->plan(130); |
28 | 28 |
29 $t->write_file_expand('nginx.conf', <<'EOF'); | 29 $t->write_file_expand('nginx.conf', <<'EOF'); |
30 | 30 |
31 %%TEST_GLOBALS%% | 31 %%TEST_GLOBALS%% |
32 | 32 |
151 is($frame->{sid}, $sid, 'request 2 - HEADERS sid again'); | 151 is($frame->{sid}, $sid, 'request 2 - HEADERS sid again'); |
152 $f->{data}('Hello'); | 152 $f->{data}('Hello'); |
153 $frames = $f->{http_end}(); | 153 $frames = $f->{http_end}(); |
154 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 154 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
155 cmp_ok($frame->{headers}{'x-connection'}, '>', $c, 'response 2 - connection'); | 155 cmp_ok($frame->{headers}{'x-connection'}, '>', $c, 'response 2 - connection'); |
156 | |
157 # request body - special last buffer | |
158 | |
159 $f->{http_start}('/SayHello'); | |
160 $frames = $f->{data}('Hello', body_more => 1); | |
161 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
162 is($frame->{data}, 'Hello', 'request body first - DATA'); | |
163 is($frame->{length}, 5, 'request body first - DATA length'); | |
164 is($frame->{flags}, 0, 'request body first - DATA flags'); | |
165 $frames = $f->{data}(''); | |
166 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
167 is($frame->{data}, '', 'special buffer last - DATA'); | |
168 is($frame->{length}, 0, 'special buffer last - DATA length'); | |
169 is($frame->{flags}, 1, 'special buffer last - DATA flags'); | |
170 $frames = $f->{http_end}(); | |
171 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
172 is($frame->{headers}{':status'}, '200', 'special buffer last - response'); | |
156 | 173 |
157 # upstream keepalive | 174 # upstream keepalive |
158 | 175 |
159 $frames = $f->{http_start}('/KeepAlive'); | 176 $frames = $f->{http_start}('/KeepAlive'); |
160 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 177 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |