comparison h2.t @ 1898:26252394dd58

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.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 30 May 2023 05:35:40 +0400
parents f3de5730bc06
children 236d038dc04a
comparison
equal deleted inserted replaced
1897:38f1fd9ca3e6 1898:26252394dd58
24 24
25 select STDERR; $| = 1; 25 select STDERR; $| = 1;
26 select STDOUT; $| = 1; 26 select STDOUT; $| = 1;
27 27
28 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite charset gzip/) 28 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite charset gzip/)
29 ->plan(144); 29 ->plan(142);
30 30
31 $t->write_file_expand('nginx.conf', <<'EOF'); 31 $t->write_file_expand('nginx.conf', <<'EOF');
32 32
33 %%TEST_GLOBALS%% 33 %%TEST_GLOBALS%%
34 34
1015 1015
1016 # some invalid cases below 1016 # some invalid cases below
1017 1017
1018 # invalid connection preface 1018 # invalid connection preface
1019 1019
1020 $s = Test::Nginx::HTTP2->new(port(8080), preface => 'x' x 16, pure => 1); 1020 TODO: {
1021 $frames = $s->read(all => [{ type => 'GOAWAY' }]); 1021 local $TODO = 'not yet' unless $t->has_version('1.25.1');
1022 1022
1023 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; 1023 like(http('x' x 16), qr/400 Bad Request/, 'invalid preface');
1024 ok($frame, 'invalid preface - GOAWAY frame'); 1024 like(http('PRI * HTTP/2.0' . CRLF . CRLF . 'x' x 8), qr/400 Bad Request/,
1025 is($frame->{code}, 1, 'invalid preface - error code'); 1025 'invalid preface 2');
1026 1026
1027 my $preface = 'PRI * HTTP/2.0' . CRLF . CRLF . 'x' x 8; 1027 }
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');
1034 1028
1035 # GOAWAY on SYN_STREAM with even StreamID 1029 # GOAWAY on SYN_STREAM with even StreamID
1036 1030
1037 $s = Test::Nginx::HTTP2->new(); 1031 $s = Test::Nginx::HTTP2->new();
1038 $s->new_stream({ path => '/' }, 2); 1032 $s->new_stream({ path => '/' }, 2);