Skip to content

Commit 6bf3030

Browse files
committed
Tests: updated HTTP/2 tests with invalid connection preface.
HTTP/1.x 400 is now expected instead of HTTP/2 GOAWAY due to HTTP/2 auto-detection fallback to HTTP/1.x.
1 parent 96f91f1 commit 6bf3030

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

h2.t

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ select STDERR; $| = 1;
2626
select STDOUT; $| = 1;
2727

2828
my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite charset gzip/)
29-
->plan(144);
29+
->plan(142);
3030

3131
$t->write_file_expand('nginx.conf', <<'EOF');
3232
@@ -1017,20 +1017,14 @@ is($frame->{headers}->{':status'}, 200, 'http2_max_concurrent_streams 3');
10171017

10181018
# invalid connection preface
10191019

1020-
$s = Test::Nginx::HTTP2->new(port(8080), preface => 'x' x 16, pure => 1);
1021-
$frames = $s->read(all => [{ type => 'GOAWAY' }]);
1020+
TODO: {
1021+
local $TODO = 'not yet' unless $t->has_version('1.25.1');
10221022

1023-
($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
1024-
ok($frame, 'invalid preface - GOAWAY frame');
1025-
is($frame->{code}, 1, 'invalid preface - error code');
1023+
like(http('x' x 16), qr/400 Bad Request/, 'invalid preface');
1024+
like(http('PRI * HTTP/2.0' . CRLF . CRLF . 'x' x 8), qr/400 Bad Request/,
1025+
'invalid preface 2');
10261026

1027-
my $preface = 'PRI * HTTP/2.0' . CRLF . CRLF . 'x' x 8;
1028-
$s = Test::Nginx::HTTP2->new(port(8080), preface => $preface, pure => 1);
1029-
$frames = $s->read(all => [{ type => 'GOAWAY' }]);
1030-
1031-
($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
1032-
ok($frame, 'invalid preface 2 - GOAWAY frame');
1033-
is($frame->{code}, 1, 'invalid preface 2 - error code');
1027+
}
10341028

10351029
# GOAWAY on SYN_STREAM with even StreamID
10361030

0 commit comments

Comments
 (0)