changeset 1733:e306bd77321d

Tests: handling of HTTP/2 PUSH_PROMISE frames with CONTINUATION.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 17 Sep 2021 18:56:36 +0300
parents 41ca4b00c2d0
children f7170c7acf3a
files lib/Test/Nginx/HTTP2.pm
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Test/Nginx/HTTP2.pm
+++ b/lib/Test/Nginx/HTTP2.pm
@@ -438,9 +438,15 @@ sub headers {
 
 sub continuation {
 	my ($ctx, $buf, $len, $flags) = @_;
+	my %payload;
+
 	$ctx->{headers} .= substr($buf, 0, $len);
-	return unless $flags & 0x4;
-	{ headers => hunpack($ctx, $ctx->{headers}, length($ctx->{headers})) };
+	$payload{promised} = $ctx->{promised} if $ctx->{promised};
+	return \%payload unless $flags & 0x4;
+
+	$ctx->{promised} = undef;
+	return { %payload, headers => hunpack($ctx, $ctx->{headers},
+		length($ctx->{headers})) };
 }
 
 sub data {
@@ -464,10 +470,13 @@ sub settings {
 
 sub push_promise {
 	my ($ctx, $buf, $len, $flags) = @_;
+	my %payload;
 	$len -= 4;
 
-	{ promised => unpack("N", $buf),
-	  headers => hunpack($ctx, substr($buf, 4, $len), $len) };
+	$ctx->{promised} = $payload{promised} = unpack("N", $buf);
+	$ctx->{headers} = substr($buf, 4, $len);
+	return \%payload unless $flags & 0x4;
+	return { %payload, headers => hunpack($ctx, $ctx->{headers}, $len) };
 }
 
 sub ping {