comparison h2.t @ 715:9ee52e137f3d

Tests: more HTTP/2 HPACK decoding tests with discarded streams.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 25 Sep 2015 23:30:39 +0300
parents ccc9f389e1f8
children e3fd2c8d257e
comparison
equal deleted inserted replaced
714:ccc9f389e1f8 715:9ee52e137f3d
1685 is($frame->{sid}, $sid2, 'http2_max_concurrent_streams RST_STREAM sid'); 1685 is($frame->{sid}, $sid2, 'http2_max_concurrent_streams RST_STREAM sid');
1686 is($frame->{length}, 4, 'http2_max_concurrent_streams RST_STREAM length'); 1686 is($frame->{length}, 4, 'http2_max_concurrent_streams RST_STREAM length');
1687 is($frame->{flags}, 0, 'http2_max_concurrent_streams RST_STREAM flags'); 1687 is($frame->{flags}, 0, 'http2_max_concurrent_streams RST_STREAM flags');
1688 is($frame->{code}, 7, 'http2_max_concurrent_streams RST_STREAM code'); 1688 is($frame->{code}, 7, 'http2_max_concurrent_streams RST_STREAM code');
1689 1689
1690 # properly skip header field that's not/never indexed from discarded streams
1691
1692 $sid2 = new_stream($sess, { headers => [
1693 { name => ':method', value => 'GET' },
1694 { name => ':scheme', value => 'http' },
1695 { name => ':path', value => '/', mode => 6 },
1696 { name => ':authority', value => 'localhost' },
1697 { name => 'x-foo', value => 'Foo', mode => 2 }]});
1698 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]);
1699
1700 # also if split across writes
1701
1702 $sid2 = new_stream($sess, { split => [ 22 ], headers => [
1703 { name => ':method', value => 'GET' },
1704 { name => ':scheme', value => 'http' },
1705 { name => ':path', value => '/', mode => 6 },
1706 { name => ':authority', value => 'localhost' },
1707 { name => 'x-bar', value => 'Bar', mode => 2 }]});
1708 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]);
1709
1710 # also if split across frames
1711
1712 $sid2 = new_stream($sess, { continuation => [ 17 ], headers => [
1713 { name => ':method', value => 'GET' },
1714 { name => ':scheme', value => 'http' },
1715 { name => ':path', value => '/', mode => 6 },
1716 { name => ':authority', value => 'localhost' },
1717 { name => 'x-baz', value => 'Baz', mode => 2 }]});
1718 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]);
1719
1690 h2_window($sess, 2**16, $sid); 1720 h2_window($sess, 2**16, $sid);
1691 h2_read($sess, all => [{ sid => $sid, fin => 1 }]); 1721 h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
1692 1722
1693 $sid = new_stream($sess, { path => '/t2.html' }); 1723 $sid = new_stream($sess, { headers => [
1724 { name => ':method', value => 'GET' },
1725 { name => ':scheme', value => 'http' },
1726 { name => ':path', value => '/t2.html' },
1727 { name => ':authority', value => 'localhost' },
1728 # make sure that discarded streams updated dynamic table
1729 { name => 'x-foo', value => 'Foo', mode => 0 },
1730 { name => 'x-bar', value => 'Bar', mode => 0 },
1731 { name => 'x-baz', value => 'Baz', mode => 0 }]});
1694 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); 1732 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
1695 1733
1696 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames; 1734 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames;
1697 is($frame->{headers}->{':status'}, 200, 'http2_max_concurrent_streams 3'); 1735 is($frame->{headers}->{':status'}, 200, 'http2_max_concurrent_streams 3');
1698 1736
1965 $buf .= pack 'CC', 0x0, 0x1 | $flags; # DATA, END_STREAM 2003 $buf .= pack 'CC', 0x0, 0x1 | $flags; # DATA, END_STREAM
1966 $buf .= pack 'N', $ctx->{last_stream}; 2004 $buf .= pack 'N', $ctx->{last_stream};
1967 $buf .= pack 'C', $bpad if $bpadlen; # DATA Pad Length? 2005 $buf .= pack 'C', $bpad if $bpadlen; # DATA Pad Length?
1968 $buf .= $body; 2006 $buf .= $body;
1969 $buf .= (pack 'C', 0) x $bpad if $bpadlen; # DATA Padding 2007 $buf .= (pack 'C', 0) x $bpad if $bpadlen; # DATA Padding
2008 }
2009
2010 $split = ref $uri->{split} && $uri->{split} || [];
2011 for (@$split) {
2012 raw_write($ctx->{socket}, substr($buf, 0, $_, ""));
2013 select undef, undef, undef, 0.2;
1970 } 2014 }
1971 2015
1972 raw_write($ctx->{socket}, $buf); 2016 raw_write($ctx->{socket}, $buf);
1973 return $ctx->{last_stream}; 2017 return $ctx->{last_stream};
1974 } 2018 }