Mercurial > hg > nginx-tests
changeset 759:6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 28 Oct 2015 00:11:44 +0300 |
parents | 70c486d09663 |
children | 4db976a91540 |
files | h2.t |
diffstat | 1 files changed, 50 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/h2.t Wed Oct 28 00:11:44 2015 +0300 +++ b/h2.t Wed Oct 28 00:11:44 2015 +0300 @@ -32,7 +32,7 @@ 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(243); + ->has_daemon('openssl')->plan(247); # Some systems may have also a bug in not treating zero writev iovcnt as EINVAL @@ -358,6 +358,41 @@ ok($frame, 'idle timeout - idle connection GOAWAY'); is($frame->{code}, 0, 'idle timeout - idle connection code'); +# GOAWAY + +h2_goaway(new_session(), 0, 0, 5); +h2_goaway(new_session(), 0, 0, 5, 'foobar'); +h2_goaway(new_session(), 0, 0, 5, 'foobar', split => [ 8, 8, 4 ]); + +$sess = new_session(); +h2_goaway($sess, 0, 0, 5); +h2_goaway($sess, 0, 0, 5); + +$sess = new_session(); +h2_goaway($sess, 0, 0, 5, 'foobar', len => 0); +$frames = h2_read($sess, all => [{ type => "GOAWAY" }]); + +($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; +ok($frame, 'GOAWAY invalid length - GOAWAY frame'); +is($frame->{code}, 6, 'GOAWAY invalid length - GOAWAY FRAME_SIZE_ERROR'); + +# 6.8. GOAWAY +# An endpoint MUST treat a GOAWAY frame with a stream identifier other +# than 0x0 as a connection error (Section 5.4.1) of type PROTOCOL_ERROR. + +TODO: { +local $TODO = 'not yet'; + +$sess = new_session(); +h2_goaway($sess, 1, 0, 5, 'foobar'); +$frames = h2_read($sess, all => [{ type => "GOAWAY" }]); + +($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; +ok($frame, 'GOAWAY invalid stream - GOAWAY frame'); +is($frame->{code}, 1, 'GOAWAY invalid stream - GOAWAY PROTOCOL_ERROR'); + +} + # GET $sess = new_session(); @@ -2451,6 +2486,20 @@ raw_write($sess->{socket}, pack("x2C2xNN", 4, 0x3, $stream, $error)); } +sub h2_goaway { + my ($sess, $stream, $lstream, $err, $debug, %extra) = @_; + $debug = '' unless defined $debug; + my $len = defined $extra{len} ? $extra{len} : 8 + length($debug); + my $buf = pack("x2C2xN3A*", $len, 0x7, $stream, $lstream, $err, $debug); + + my @bufs = map { + raw_write($sess->{socket}, substr $buf, 0, $_, ""); + select undef, undef, undef, 0.4; + } @{$extra{split}}; + + raw_write($sess->{socket}, $buf); +} + sub h2_priority { my ($sess, $w, $stream, $dep, %extra) = @_;