# HG changeset patch # User Sergey Kandaurov # Date 1481107888 -10800 # Node ID eedb96f717ff801ee2fd84f8995e86a9bbc5dfd4 # Parent 83b7b3f8b6c5f83a970c6cbd2a25886760bfaf30 Tests: reset headers context when parsing HEADERS frame. This fixes parsing several HEADERS frames from different streams. diff --git a/lib/Test/Nginx/HTTP2.pm b/lib/Test/Nginx/HTTP2.pm --- a/lib/Test/Nginx/HTTP2.pm +++ b/lib/Test/Nginx/HTTP2.pm @@ -28,7 +28,7 @@ my %cframe = ( 6 => { name => 'PING', value => \&ping }, 7 => { name => 'GOAWAY', value => \&goaway }, 8 => { name => 'WINDOW_UPDATE', value => \&window_update }, - 9 => { name => 'CONTINUATION', value => \&headers }, + 9 => { name => 'CONTINUATION', value => \&continuation }, ); sub new { @@ -371,6 +371,13 @@ sub test_fin { sub headers { my ($ctx, $buf, $len, $flags) = @_; + $ctx->{headers} = substr($buf, 0, $len); + return unless $flags & 0x4; + { headers => hunpack($ctx, $buf, $len) }; +} + +sub continuation { + my ($ctx, $buf, $len, $flags) = @_; $ctx->{headers} .= substr($buf, 0, $len); return unless $flags & 0x4; { headers => hunpack($ctx, $ctx->{headers}, length($ctx->{headers})) };