# HG changeset patch # User Sergey Kandaurov # Date 1518610255 -10800 # Node ID b50c8b9a76448f3b725ad32afe3c887b6f95d289 # Parent aaf332b74bcfb17a0e445f7d2f5fc54c55a20739 Tests: added HTTP/2 $request_length tests. diff --git a/h2_variables.t b/h2_variables.t --- a/h2_variables.t +++ b/h2_variables.t @@ -23,7 +23,7 @@ use Test::Nginx::HTTP2; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http http_v2 rewrite/)->plan(4) +my $t = Test::Nginx->new()->has(qw/http http_v2 rewrite/)->plan(6) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -52,6 +52,9 @@ http { location /https { return 200 $https; } + location /rl { + return 200 $request_length; + } } } @@ -97,4 +100,31 @@ is($frame->{data}, 'http', 'scheme varia ($frame) = grep { $_->{type} eq "DATA" } @$frames; is($frame->{data}, '', 'https variable'); +# $request_length, HEADERS payload length + +$s = Test::Nginx::HTTP2->new(); +$sid = $s->new_stream({ headers => [ + { name => ':method', value => 'GET', mode => 0 }, # 1 + { name => ':scheme', value => 'http', mode => 0 }, # 1 + { name => ':authority', value => 'localhost', mode => 1 }, # 1+1+9 + { name => ':path', value => '/rl', mode => 1 }]}); # 1+1+3 +$frames = $s->read(all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, '18', 'request length'); + +# $request_length, HEADERS+CONTINUATION payload length + +$s = Test::Nginx::HTTP2->new(); +$sid = $s->new_stream({ continuation => 1, headers => [ + { name => ':method', value => 'GET', mode => 0 }, # 1 + { name => ':authority', value => 'localhost', mode => 1 }, # 1+1+9 + { name => ':path', value => '/rl', mode => 1 }]}); # 1+1+3 +$s->h2_continue($sid, { headers => [ + { name => ':scheme', value => 'http', mode => 0 }]}); # 1 +$frames = $s->read(all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, '18', 'request length'); + ###############################################################################