Mercurial > hg > nginx-tests
changeset 1728:6d5ecf445e57
Tests: added HTTP/2 test with big request body.
Notably, it is useful with body buffering in filters, in which case
the stream window is flow controlled based on the preread buffer.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Sat, 04 Sep 2021 14:50:02 +0300 |
parents | bdefe70ae1a7 |
children | 14b5ee6eee6c |
files | h2_request_body.t |
diffstat | 1 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/h2_request_body.t Thu Sep 02 19:30:06 2021 +0000 +++ b/h2_request_body.t Sat Sep 04 14:50:02 2021 +0300 @@ -23,7 +23,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/)->plan(45); +my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/)->plan(49); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -138,6 +138,33 @@ is($frame->{headers}->{'x-length'}, 12, 'request body in multiple frames separately - content length'); +# if run with body buffering in filters, it's expected to update window +# after request body populates initial stream window size set for preread + +$s = Test::Nginx::HTTP2->new(); +$sid = $s->new_stream({ path => '/proxy2/t.html', body_more => 1 }); +$s->h2_body('01234567' x 2048, { body_more => 1 }); +select undef, undef, undef, 0.1; +$s->h2_body('01234567' x 2048, { body_more => 1 }); +select undef, undef, undef, 0.1; +$s->h2_body('01234567' x 2048, { body_more => 1 }); +select undef, undef, undef, 0.1; +$s->h2_body('01234567' x 2048, { body_more => 1 }); + +$frames = $s->read(all => [{ type => 'WINDOW_UPDATE' }]); +($frame) = grep { $_->{type} eq 'WINDOW_UPDATE' } @$frames; +is($frame->{sid}, $sid, 'big request body - WINDOW_UPDATE sid'); +cmp_ok($frame->{wdelta}, '>=', 65536, 'big request body - WINDOW_UPDATE delta'); + +$s->h2_body('01234567' x 2048); + +$frames = $s->read(all => [{ sid => $sid, fin => 1 }]); +($frame) = grep { $_->{type} eq "HEADERS" } @$frames; +is(read_body_file($frame->{headers}->{'x-body-file'}), '01234567' x 10240, + 'big request body - content'); +is($frame->{headers}->{'x-length'}, 81920, + 'big request body - content length'); + # request body with an empty DATA frame # "zero size buf in output" alerts seen