changeset 1286:b50c8b9a7644

Tests: added HTTP/2 $request_length tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 14 Feb 2018 15:10:55 +0300
parents aaf332b74bcf
children b575be896b99
files h2_variables.t
diffstat 1 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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');
+
 ###############################################################################