[PATCH] Tests: HTTP/2 response header length checking tests
Maxim Dounin
mdounin at mdounin.ru
Sat Jun 13 10:43:48 UTC 2026
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1781347331 -10800
# Sat Jun 13 13:42:11 2026 +0300
# Node ID e0642736380fdbce13153863dc0c41faf026bdc2
# Parent 2cbaa4b88c1dc8a7c3b329c220daa4e5a9c92b18
Tests: HTTP/2 response header length checking tests.
diff --git a/h2_headers.t b/h2_headers.t
--- a/h2_headers.t
+++ b/h2_headers.t
@@ -23,7 +23,7 @@ use Test::Nginx::HTTP2;
select STDERR; $| = 1;
select STDOUT; $| = 1;
-my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(103)
+my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(105)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
@@ -87,6 +87,23 @@ http {
add_header X-Cookie-c $cookie_c;
return 200;
}
+ location /long_value {
+ set $a $args;
+ set $a $a$a$a$a$a$a$a$a$a$a;
+ set $a $a$a$a$a$a$a$a$a$a$a;
+ set $a $a$a$a$a$a$a$a$a$a$a;
+ set $a $a$a$a$a$a$a$a$a$a$a;
+ add_header X-Long $a;
+ return 200;
+ }
+ location /long_location {
+ set $a $args;
+ set $a $a$a$a$a$a$a$a$a$a$a;
+ set $a $a$a$a$a$a$a$a$a$a$a;
+ set $a $a$a$a$a$a$a$a$a$a$a;
+ set $a $a$a$a$a$a$a$a$a$a$a;
+ return 302 $a;
+ }
}
server {
@@ -624,6 +641,29 @@ is($frame->{headers}->{'x-uc-a'}, 'b',
is($frame->{headers}->{'x-uc-c'}, 'd',
'multiple response header proxied - upstream cookie 2');
+# too long response header value
+
+$s = Test::Nginx::HTTP2->new();
+$sid = $s->new_stream({ path => '/long_value?' . ('~' x 210) });
+$frames = $s->read(all => [{ type => 'RST_STREAM' }], wait => 0.5);
+
+($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames;
+is($frame->{code}, 2, 'too long response header value');
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.31.3');
+
+# too long Location response header value
+
+$s = Test::Nginx::HTTP2->new();
+$sid = $s->new_stream({ path => '/long_location?' . ('~' x 210) });
+$frames = $s->read(all => [{ type => 'RST_STREAM' }], wait => 0.5);
+
+($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames;
+is($frame->{code}, 2, 'too long response location');
+
+}
+
# CONTINUATION in response
# put three long header fields (not less than SETTINGS_MAX_FRAME_SIZE/2)
# to break header block into separate frames, one such field per frame
More information about the nginx-devel
mailing list