# HG changeset patch # User Sergey Kandaurov # Date 1622720338 -10800 # Node ID 90201294e1b682731fd1fe6607d82b70374baf0a # Parent 5386f4328b90099eeec0857dab9e3aae578863b9 Tests: added grpc request body test with a special last buffer. diff --git a/grpc.t b/grpc.t --- a/grpc.t +++ b/grpc.t @@ -24,7 +24,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; my $t = Test::Nginx->new()->has(qw/http rewrite http_v2 grpc/) - ->has(qw/upstream_keepalive/)->plan(123); + ->has(qw/upstream_keepalive/)->plan(130); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -154,6 +154,23 @@ is($frame->{sid}, $sid, 'request 2 - HEA ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; cmp_ok($frame->{headers}{'x-connection'}, '>', $c, 'response 2 - connection'); +# request body - special last buffer + +$f->{http_start}('/SayHello'); +$frames = $f->{data}('Hello', body_more => 1); +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, 'Hello', 'request body first - DATA'); +is($frame->{length}, 5, 'request body first - DATA length'); +is($frame->{flags}, 0, 'request body first - DATA flags'); +$frames = $f->{data}(''); +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, '', 'special buffer last - DATA'); +is($frame->{length}, 0, 'special buffer last - DATA length'); +is($frame->{flags}, 1, 'special buffer last - DATA flags'); +$frames = $f->{http_end}(); +($frame) = grep { $_->{type} eq "HEADERS" } @$frames; +is($frame->{headers}{':status'}, '200', 'special buffer last - response'); + # upstream keepalive $frames = $f->{http_start}('/KeepAlive');