Mercurial > hg > nginx-tests
comparison lib/Test/Nginx/HTTP2.pm @ 1089:eedb96f717ff
Tests: reset headers context when parsing HEADERS frame.
This fixes parsing several HEADERS frames from different streams.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 07 Dec 2016 13:51:28 +0300 |
parents | 4a915c4489cc |
children | eb813f7e0bfa |
comparison
equal
deleted
inserted
replaced
1088:83b7b3f8b6c5 | 1089:eedb96f717ff |
---|---|
26 4 => { name => 'SETTINGS', value => \&settings }, | 26 4 => { name => 'SETTINGS', value => \&settings }, |
27 # 5 => { name => 'PUSH_PROMISE', value => \&push_promise }, | 27 # 5 => { name => 'PUSH_PROMISE', value => \&push_promise }, |
28 6 => { name => 'PING', value => \&ping }, | 28 6 => { name => 'PING', value => \&ping }, |
29 7 => { name => 'GOAWAY', value => \&goaway }, | 29 7 => { name => 'GOAWAY', value => \&goaway }, |
30 8 => { name => 'WINDOW_UPDATE', value => \&window_update }, | 30 8 => { name => 'WINDOW_UPDATE', value => \&window_update }, |
31 9 => { name => 'CONTINUATION', value => \&headers }, | 31 9 => { name => 'CONTINUATION', value => \&continuation }, |
32 ); | 32 ); |
33 | 33 |
34 sub new { | 34 sub new { |
35 my $class = shift; | 35 my $class = shift; |
36 my ($port, %extra) = @_; | 36 my ($port, %extra) = @_; |
368 | 368 |
369 @{$all} = @test; | 369 @{$all} = @test; |
370 } | 370 } |
371 | 371 |
372 sub headers { | 372 sub headers { |
373 my ($ctx, $buf, $len, $flags) = @_; | |
374 $ctx->{headers} = substr($buf, 0, $len); | |
375 return unless $flags & 0x4; | |
376 { headers => hunpack($ctx, $buf, $len) }; | |
377 } | |
378 | |
379 sub continuation { | |
373 my ($ctx, $buf, $len, $flags) = @_; | 380 my ($ctx, $buf, $len, $flags) = @_; |
374 $ctx->{headers} .= substr($buf, 0, $len); | 381 $ctx->{headers} .= substr($buf, 0, $len); |
375 return unless $flags & 0x4; | 382 return unless $flags & 0x4; |
376 { headers => hunpack($ctx, $ctx->{headers}, length($ctx->{headers})) }; | 383 { headers => hunpack($ctx, $ctx->{headers}, length($ctx->{headers})) }; |
377 } | 384 } |