changeset 1734:f7170c7acf3a

Tests: added HTTP/2 tests for PUSH_PROMISE with CONTINUATION.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 17 Sep 2021 19:16:31 +0300
parents e306bd77321d
children 8bdf548487f6
files h2_server_push.t
diffstat 1 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/h2_server_push.t
+++ b/h2_server_push.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 proxy rewrite gzip/)->plan(42)
+my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite gzip/)->plan(54)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -106,6 +106,11 @@ http {
             return 204;
         }
 
+        location /continuation {
+            http2_push /push?arg="$args$args$args$args";
+            return 204;
+        }
+
         location /push {
             return 200 PROMISED;
         }
@@ -420,6 +425,30 @@ gunzip_like($frame->{data}, qr/^PROMISED
 ($frame) = grep { $_->{type} eq "PUSH_PROMISE" && $_->{sid} == $sid } @$frames;
 is($frame->{headers}->{':scheme'}, 'https', 'scheme https');
 
+# CONTINUATION
+
+$s = Test::Nginx::HTTP2->new();
+$sid = $s->new_stream({ path => '/continuation?x=' . ('X' x 4096) });
+$frames = $s->read(all => [{ sid => 1, fin => 1 }, { sid => 2, fin => 1 }]);
+
+@$frames = grep { $_->{promised} } @$frames;
+is(@$frames, 2, 'continuation - frames');
+
+$frame = shift @$frames;
+is($frame->{type}, 'PUSH_PROMISE', 'continuation - PUSH_PROMISE');
+is($frame->{length}, 16384, 'continuation - PUSH_PROMISE length');
+is($frame->{flags}, 0, 'continuation - PUSH_PROMISE flags');
+is($frame->{sid}, $sid, 'continuation - PUSH_PROMISE sid');
+is($frame->{promised}, 2, 'continuation - promised stream');
+
+$frame = shift @$frames;
+is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION');
+is($frame->{flags}, 4, 'continuation - CONTINUATION flags');
+is($frame->{headers}->{':authority'}, 'localhost', 'continuation - authority');
+is($frame->{headers}->{':scheme'}, 'http', 'continuation - scheme');
+is($frame->{headers}->{':method'}, 'GET', 'continuation - method');
+like($frame->{headers}->{':path'}, qr!^/push!, 'continuation - path');
+
 ###############################################################################
 
 sub gunzip_like {