@@ -23,7 +23,7 @@ use Test::Nginx::HTTP2;
23
23
select STDERR ; $| = 1;
24
24
select STDOUT ; $| = 1;
25
25
26
- my $t = Test::Nginx-> new()-> has(qw/ http http_v2 proxy rewrite/ )-> plan(107 )
26
+ my $t = Test::Nginx-> new()-> has(qw/ http http_v2 proxy rewrite/ )-> plan(103 )
27
27
-> write_file_expand(' nginx.conf' , <<'EOF' );
28
28
29
29
%%TEST_GLOBALS%%
@@ -943,7 +943,7 @@ $sid = $s->new_stream({ headers => [
943
943
{ name => ' :path' , value => ' /proxy2/' , mode => 1 },
944
944
{ name => ' :authority' , value => ' localhost' , mode => 1 },
945
945
{ name => ' x-foo' , value => " x-bar\r\n referer:see-this" , mode => 2 }]});
946
- $frames = $s -> read (all => [{ type => ' RST_STREAM ' }]);
946
+ $frames = $s -> read (all => [{ sid => $sid , fin => 1 }]);
947
947
948
948
# 10.3. Intermediary Encapsulation Attacks
949
949
# An intermediary therefore cannot translate an HTTP/2 request or response
@@ -952,15 +952,12 @@ $frames = $s->read(all => [{ type => 'RST_STREAM' }]);
952
952
($frame ) = grep { $_ -> {type } eq " HEADERS" } @$frames ;
953
953
isnt($frame -> {headers }-> {' x-referer' }, ' see-this' , ' newline in request header' );
954
954
955
- # 8.1.2.6. Malformed Requests and Responses
956
- # Malformed requests or responses that are detected MUST be treated
957
- # as a stream error (Section 5.4.2) of type PROTOCOL_ERROR.
955
+ TODO: {
956
+ local $TODO = ' not yet' unless $t -> has_version(' 1.23.4' );
957
+
958
+ is($frame -> {headers }-> {' :status' }, 400, ' newline in request header - bad request' );
958
959
959
- ($frame ) = grep { $_ -> {type } eq " RST_STREAM" } @$frames ;
960
- is($frame -> {sid }, $sid , ' newline in request header - RST_STREAM sid' );
961
- is($frame -> {length }, 4, ' newline in request header - RST_STREAM length' );
962
- is($frame -> {flags }, 0, ' newline in request header - RST_STREAM flags' );
963
- is($frame -> {code }, 1, ' newline in request header - RST_STREAM code' );
960
+ }
964
961
965
962
# invalid header name as seen with underscore should not lead to ignoring rest
966
963
@@ -977,7 +974,10 @@ $frames = $s->read(all => [{ type => 'HEADERS' }]);
977
974
($frame ) = grep { $_ -> {type } eq " HEADERS" } @$frames ;
978
975
is($frame -> {headers }-> {' x-referer' }, ' see-this' , ' after invalid header name' );
979
976
980
- # other invalid header name characters as seen with ':' result in RST_STREAM
977
+ # other invalid header name characters as seen with ':'
978
+
979
+ TODO: {
980
+ local $TODO = ' not yet' unless $t -> has_version(' 1.23.4' );
981
981
982
982
$s = Test::Nginx::HTTP2-> new();
983
983
$sid = $s -> new_stream({ headers => [
@@ -987,14 +987,10 @@ $sid = $s->new_stream({ headers => [
987
987
{ name => ' :authority' , value => ' localhost' , mode => 1 },
988
988
{ name => ' x:foo' , value => " x-bar" , mode => 2 },
989
989
{ name => ' referer' , value => " see-this" , mode => 1 }]});
990
- $frames = $s -> read (all => [{ type => ' RST_STREAM' }]);
991
-
992
- ($frame ) = grep { $_ -> {type } eq " RST_STREAM" } @$frames ;
993
- is($frame -> {sid }, $sid , ' colon in header name - RST_STREAM sid' );
994
- is($frame -> {code }, 1, ' colon in header name - RST_STREAM code' );
990
+ $frames = $s -> read (all => [{ sid => $sid , fin => 1 }]);
995
991
996
- TODO: {
997
- local $TODO = ' not yet ' unless $t -> has_version( ' 1.21.1 ' );
992
+ ( $frame ) = grep { $_ -> { type } eq " HEADERS " } @$frames ;
993
+ is( $frame -> { headers } -> { ' :status ' }, 400, ' colon in header name ' );
998
994
999
995
$s = Test::Nginx::HTTP2-> new();
1000
996
$sid = $s -> new_stream({ headers => [
@@ -1003,10 +999,10 @@ $sid = $s->new_stream({ headers => [
1003
999
{ name => ' :path' , value => ' /' , mode => 0 },
1004
1000
{ name => ' :authority' , value => ' localhost' , mode => 1 },
1005
1001
{ name => ' x foo' , value => " bar" , mode => 2 }]});
1006
- $frames = $s -> read (all => [{ type => ' RST_STREAM ' }]);
1002
+ $frames = $s -> read (all => [{ sid => $sid , fin => 1 }]);
1007
1003
1008
- ($frame ) = grep { $_ -> {type } eq " RST_STREAM " } @$frames ;
1009
- ok ($frame , ' space in header name - RST_STREAM sid ' );
1004
+ ($frame ) = grep { $_ -> {type } eq " HEADERS " } @$frames ;
1005
+ is ($frame -> { headers } -> { ' :status ' }, 400, ' space in header name' );
1010
1006
1011
1007
$s = Test::Nginx::HTTP2-> new();
1012
1008
$sid = $s -> new_stream({ headers => [
@@ -1015,10 +1011,10 @@ $sid = $s->new_stream({ headers => [
1015
1011
{ name => ' :path' , value => ' /' , mode => 0 },
1016
1012
{ name => ' :authority' , value => ' localhost' , mode => 1 },
1017
1013
{ name => " foo\x02 " , value => " bar" , mode => 2 }]});
1018
- $frames = $s -> read (all => [{ type => ' RST_STREAM ' }]);
1014
+ $frames = $s -> read (all => [{ sid => $sid , fin => 1 }]);
1019
1015
1020
- ($frame ) = grep { $_ -> {type } eq " RST_STREAM " } @$frames ;
1021
- ok ($frame , ' control in header name - RST_STREAM sid ' );
1016
+ ($frame ) = grep { $_ -> {type } eq " HEADERS " } @$frames ;
1017
+ is ($frame -> { headers } -> { ' :status ' }, 400, ' control in header name' );
1022
1018
1023
1019
}
1024
1020
0 commit comments