Changeset 1549:6c9e3e20af97 in nginx-tests


Ignore:
Timestamp:
02/05/20 15:04:55 (13 days ago)
Author:
Sergey Kandaurov <pluknet@…>
Branch:
default
Phase:
public
Message:

Tests: HTTP/2 tests for error handling in parsing HPACK integers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • h2_headers.t

    r1522 r1549  
    2424select STDOUT; $| = 1;
    2525
    26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(97)
     26my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(103)
    2727        ->write_file_expand('nginx.conf', <<'EOF');
    2828
     
    10481048is($frame->{headers}->{':status'}, 400, 'invalid path');
    10491049
     1050
     1051# ngx_http_v2_parse_int() error handling
     1052
     1053# NGX_ERROR
     1054
     1055$s = Test::Nginx::HTTP2->new();
     1056{
     1057        local $SIG{PIPE} = 'IGNORE';
     1058        syswrite($s->{socket}, pack("x2C3NC", 1, 0x1, 5, 1, 0xff));
     1059}
     1060$frames = $s->read(all => [{ type => "GOAWAY" }]);
     1061
     1062($frame) = grep { $_->{type} eq 'GOAWAY' } @$frames;
     1063is($frame->{code}, 0x6, 'invalid index length');
     1064
     1065$s = Test::Nginx::HTTP2->new();
     1066{
     1067        local $SIG{PIPE} = 'IGNORE';
     1068        syswrite($s->{socket}, pack("x2C3NC2", 2, 0x1, 5, 1, 0x42, 0xff));
     1069}
     1070$frames = $s->read(all => [{ type => "GOAWAY" }]);
     1071
     1072($frame) = grep { $_->{type} eq 'GOAWAY' } @$frames;
     1073is($frame->{code}, 0x6, 'invalid literal length');
     1074
     1075# NGX_DECLINED
     1076
     1077$s = Test::Nginx::HTTP2->new();
     1078{
     1079        local $SIG{PIPE} = 'IGNORE';
     1080        syswrite($s->{socket}, pack("x2C3NN", 5, 0x1, 5, 1, 0xffffffff));
     1081}
     1082$frames = $s->read(all => [{ type => "GOAWAY" }]);
     1083
     1084($frame) = grep { $_->{type} eq 'GOAWAY' } @$frames;
     1085is($frame->{code}, 0x9, 'too long index');
     1086
     1087$s = Test::Nginx::HTTP2->new();
     1088{
     1089        local $SIG{PIPE} = 'IGNORE';
     1090        syswrite($s->{socket}, pack("x2C3NCN", 6, 0x1, 5, 1, 0x42, 0xffffffff));
     1091}
     1092$frames = $s->read(all => [{ type => "GOAWAY" }]);
     1093
     1094($frame) = grep { $_->{type} eq 'GOAWAY' } @$frames;
     1095is($frame->{code}, 0x9, 'too long literal');
     1096
     1097# NGX_AGAIN
     1098
     1099$s = Test::Nginx::HTTP2->new();
     1100$sid = $s->new_stream({ split => [35], split_delay => 1.1, headers => [
     1101        { name => ':method', value => 'GET', mode => 3, huff => 0 },
     1102        { name => ':scheme', value => 'http', mode => 3, huff => 0 },
     1103        { name => ':path', value => '/', mode => 3, huff => 0 },
     1104        { name => ':authority', value => 'localhost', mode => 3, huff => 0 },
     1105        { name => 'referer', value => 'foo', mode => 3, huff => 0 }]});
     1106$frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
     1107
     1108($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
     1109is($frame->{headers}->{'x-referer'}, 'foo', 'header split index');
     1110
     1111$s = Test::Nginx::HTTP2->new();
     1112$sid = $s->new_stream({ split => [37], split_delay => 1.1, headers => [
     1113        { name => ':method', value => 'GET', mode => 3, huff => 0 },
     1114        { name => ':scheme', value => 'http', mode => 3, huff => 0 },
     1115        { name => ':path', value => '/', mode => 3, huff => 0 },
     1116        { name => ':authority', value => 'localhost', mode => 3, huff => 0 },
     1117        { name => 'referer', value => '1234' x 32, mode => 3, huff => 0 }]});
     1118$frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
     1119
     1120($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
     1121is($frame->{headers}->{'x-referer'}, '1234' x 32, 'header split field length');
     1122
    10501123###############################################################################
    10511124
Note: See TracChangeset for help on using the changeset viewer.