changeset 1883:ff50c265a5ac

Tests: HTTP/3 tests with streams blocked on insert count. As QUIC streams are run postponed, make sure to give it a chance to run before receiving RESET_STREAM, such that the request is read.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 13 Jan 2023 17:12:21 +0400
parents 3619dcc8ba6d
children 6f1508d53a26
files h3_headers.t lib/Test/Nginx/HTTP3.pm
diffstat 2 files changed, 28 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/h3_headers.t
+++ b/h3_headers.t
@@ -27,7 +27,7 @@ eval { require Crypt::Misc; die if $Cryp
 plan(skip_all => 'CryptX version >= 0.067 required') if $@;
 
 my $t = Test::Nginx->new()->has(qw/http http_v3 proxy rewrite/)
-	->has_daemon('openssl')->plan(66)
+	->has_daemon('openssl')->plan(68)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -110,6 +110,13 @@ http {
         ignore_invalid_headers off;
         add_header X-Sent-Foo $http_x_foo always;
     }
+
+    server {
+        listen       127.0.0.1:%%PORT_8988_UDP%% quic;
+        server_name  localhost;
+
+        client_header_timeout 1s;
+    }
 }
 
 EOF
@@ -854,6 +861,25 @@ is($frame->{headers}->{':status'}, 400, 
 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
 is($frame->{headers}->{':status'}, 400, 'invalid path control');
 
+# stream blocked on insert count
+
+$s = Test::Nginx::HTTP3->new();
+$sid = $s->new_stream({ ric => 3 });
+select undef, undef, undef, 0.2;
+
+$s->reset_stream($sid, 0x010c);
+$frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
+
+($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
+is($frame->{headers}->{':status'}, '400', 'blocked insert reset - bad request');
+
+$s = Test::Nginx::HTTP3->new(8988);
+$sid = $s->new_stream({ ric => 3 });
+$frames = $s->read(all => [{ type => 'RESET_STREAM' }]);
+
+($frame) = grep { $_->{type} eq "RESET_STREAM" } @$frames;
+is($frame->{sid}, $sid, 'blocked insert timeout - RESET_STREAM');
+
 ###############################################################################
 
 sub http_daemon {
--- a/lib/Test/Nginx/HTTP3.pm
+++ b/lib/Test/Nginx/HTTP3.pm
@@ -419,7 +419,7 @@ sub new_stream {
 	# encoded field section prefix
 
 	my $table = $self->{dynamic_encode};
-	my $ric = scalar @$table ? scalar @$table + 1 : 0;
+	my $ric = $uri->{ric} ? $uri->{ric} : @$table ? @$table + 1 : 0;
 	my $base = $uri->{base} || 0;
 	$base = $base < 0 ? 0x80 + abs($base) - 1 : $base;
 	$input = pack("CC", $ric, $base) . $input;