Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
diff --git a/grpc.t b/grpc.t
index 64f0f30..73bdb60 100644
--- a/grpc.t
+++ b/grpc.t
@@ -737,17 +737,16 @@
# stick trailers and subsequent frames for reproducibility
- my $fld = $c->hpack('grpc-status', '0', mode => 2);
- my $trailers = pack("x2CCCN", length($fld), 1, 5, $sid) . $fld;
- my $window = pack("xxCCCNN", 4, 8, 0, $sid, 42);
- my $rst = pack("x2C2xNN", 4, 3, $sid, 0);
- my $cnl = pack("x2C2xNN", 4, 3, $sid, 8);
-
- $trailers .= $window if $uri eq '/Discard_WU';
- $trailers .= $rst if $uri eq '/Discard_NE';
- $trailers .= ($rst x 3) if $uri eq '/Discard_NE3';
- $trailers .= $cnl if $uri eq '/Discard_CNL';
- $c->raw_write($trailers);
+ $c->start_chain();
+ $c->new_stream({ headers => [
+ { name => 'grpc-status', value => '0', mode => 2 }
+ ]}, $sid);
+ $c->h2_window(42, $sid) if $uri eq '/Discard_WU';
+ $c->h2_rst($sid, 0) if $uri eq '/Discard_NE';
+ $c->h2_rst($sid, 0), $c->h2_rst($sid, 0), $c->h2_rst($sid, 0)
+ if $uri eq '/Discard_NE3';
+ $c->h2_rst($sid, 8) if $uri eq '/Discard_CNL';
+ $c->send_chain();
return $s->read(all => [{ fin => 1 }], wait => 2)
if $uri eq '/Discard_WU' || $uri eq '/Discard_NE';
diff --git a/lib/Test/Nginx/HTTP2.pm b/lib/Test/Nginx/HTTP2.pm
index e1a4b1a..989a0d5 100644
--- a/lib/Test/Nginx/HTTP2.pm
+++ b/lib/Test/Nginx/HTTP2.pm
@@ -337,6 +337,11 @@
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 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 {