# HG changeset patch # User Sergey Kandaurov # Date 1442331633 -10800 # Node ID 46f698a7e59ce012570e9a5fbb53e6483cd126cd # Parent beab9da9b73111a0f1601156706641d48f8e43cc Tests: added HTTP/2 test for unknown frame type. diff --git a/h2.t b/h2.t --- a/h2.t +++ b/h2.t @@ -32,7 +32,7 @@ plan(skip_all => 'IO::Socket::SSL too ol my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) ->has(qw/limit_conn rewrite realip shmem/) - ->has_daemon('openssl')->plan(193); + ->has_daemon('openssl')->plan(194); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -1712,6 +1712,16 @@ is($frame->{headers}->{':status'}, 400, ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; is($frame->{headers}->{':status'}, 400, 'empty authority'); +# unknown frame type + +$sess = new_session(); +h2_unknown($sess, 'payload'); +h2_ping($sess, 'SEE-THIS'); +$frames = h2_read($sess, all => [{ type => 'PING' }]); + +($frame) = grep { $_->{type} eq "PING" } @$frames; +is($frame->{value}, 'SEE-THIS', 'unknown frame type'); + # GOAWAY - force closing a connection by server $sid = new_stream($sess, { path => 't1.html' }); @@ -1762,6 +1772,13 @@ sub h2_settings { raw_write($sess->{socket}, $buf); } +sub h2_unknown { + my ($sess, $payload) = @_; + + my $buf = pack_length(length($payload)) . pack("Cx5a*", 0xa, $payload); + raw_write($sess->{socket}, $buf); +} + sub h2_continue { my ($ctx, $stream, $uri) = @_;