diff lib/Test/Nginx/HTTP2.pm @ 1623:3fe652bc9dae

Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 24 Nov 2020 01:23:01 +0000
parents 5b3d33b5556c
children e306bd77321d
line wrap: on
line diff
--- a/lib/Test/Nginx/HTTP2.pm
+++ b/lib/Test/Nginx/HTTP2.pm
@@ -337,6 +337,11 @@ sub raw_read {
 
 sub raw_write {
 	my ($self, $message) = @_;
+
+	if ($self->{chaining}) {
+		return add_chain($self, $message);
+	}
+
 	my $s = $self->{socket};
 
 	local $SIG{PIPE} = 'IGNORE';
@@ -350,6 +355,30 @@ sub raw_write {
 	}
 }
 
+sub start_chain {
+	my ($self) = @_;
+
+	$self->{chaining} = 1;
+}
+
+sub add_chain {
+	my ($self, $buf) = @_;
+
+	if ($self->{chained_buf}) {
+		$self->{chained_buf} .= $buf;
+	} else {
+		$self->{chained_buf} = $buf;
+	}
+}
+
+sub send_chain {
+	my ($self) = @_;
+
+	undef $self->{chaining};
+	$self->raw_write($self->{chained_buf}) if $self->{chained_buf};
+	undef $self->{chained_buf};
+}
+
 ###############################################################################
 
 sub pack_body {