Mercurial > hg > nginx-tests
annotate h2_trailers.t @ 1912:f61d1b4ac638
Tests: unbreak quic_ciphers.t with AEAD_AES_128_CCM enabled.
Although CCM ciphers are disabled in a stock OpenSSL as rarely used,
"to reduce ClientHello bloat", AEAD_AES_128_CCM is apparently turned
back in certain distributions such as RHEL. Previously, this caused
testing connections to fail as the CCM cipher being negotiated isn't
supported yet in nginx. Now the test is skipped instead on failure.
While here, fixed nearby style.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 14 Jun 2023 16:57:01 +0400 |
parents | 236d038dc04a |
children | 11463d379570 |
rev | line source |
---|---|
1193 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for HTTP/2 trailers. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 use Test::Nginx::HTTP2; | |
20 | |
21 ############################################################################### | |
22 | |
23 select STDERR; $| = 1; | |
24 select STDOUT; $| = 1; | |
25 | |
1381
97c8280de681
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1194
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v2/)->plan(22) |
1193 | 27 ->write_file_expand('nginx.conf', <<'EOF'); |
28 | |
29 %%TEST_GLOBALS%% | |
30 | |
31 daemon off; | |
32 | |
33 events { | |
34 } | |
35 | |
36 http { | |
37 %%TEST_GLOBALS_HTTP%% | |
38 | |
39 server { | |
40 listen 127.0.0.1:8080 http2; | |
41 server_name localhost; | |
42 | |
43 location / { | |
44 add_trailer X-Var $host; | |
45 } | |
46 | |
47 location /continuation { | |
48 # many trailers to send in parts | |
49 add_trailer X-LongHeader $arg_h; | |
50 add_trailer X-LongHeader $arg_h; | |
51 add_trailer X-LongHeader $arg_h; | |
52 add_trailer X-LongHeader $arg_h; | |
53 add_trailer X-LongHeader $arg_h; | |
54 } | |
55 } | |
56 } | |
57 | |
58 EOF | |
59 | |
60 $t->write_file('index.html', 'SEE-THIS'); | |
61 $t->write_file('empty', ''); | |
62 $t->write_file('continuation', 'SEE-THIS'); | |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1646
diff
changeset
|
63 |
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1646
diff
changeset
|
64 # suppress deprecation warning |
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1646
diff
changeset
|
65 |
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1646
diff
changeset
|
66 open OLDERR, ">&", \*STDERR; close STDERR; |
1381
97c8280de681
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1194
diff
changeset
|
67 $t->run(); |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1646
diff
changeset
|
68 open STDERR, ">&", \*OLDERR; |
1193 | 69 |
70 ############################################################################### | |
71 | |
72 my ($s, $sid, $frames, $frame); | |
73 | |
74 $s = Test::Nginx::HTTP2->new(); | |
75 $sid = $s->new_stream({ path => '/' }); | |
76 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | |
77 @$frames = grep { $_->{type} =~ "HEADERS|DATA" } @$frames; | |
78 | |
79 is(@$frames, 3, 'frames'); | |
80 | |
81 $frame = shift @$frames; | |
82 is($frame->{headers}->{':status'}, 200, 'header'); | |
83 is($frame->{headers}->{'x-var'}, undef, 'header not trailer'); | |
84 is($frame->{flags}, 4, 'header flags'); | |
85 | |
86 $frame = shift @$frames; | |
87 is($frame->{data}, 'SEE-THIS', 'data'); | |
88 is($frame->{flags}, 0, 'data flags'); | |
89 | |
90 $frame = shift @$frames; | |
91 is($frame->{headers}->{'x-var'}, 'localhost', 'trailer'); | |
92 is($frame->{flags}, 5, 'trailer flags'); | |
93 | |
94 # with zero content-length | |
95 | |
96 $s = Test::Nginx::HTTP2->new(); | |
97 $sid = $s->new_stream({ path => '/empty' }); | |
98 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | |
99 @$frames = grep { $_->{type} =~ "HEADERS|DATA" } @$frames; | |
100 | |
101 is(@$frames, 2, 'no data - frames'); | |
102 | |
103 $frame = shift @$frames; | |
104 is($frame->{headers}->{':status'}, 200, 'no data - header'); | |
105 is($frame->{flags}, 4, 'no data - header flags'); | |
106 | |
107 $frame = shift @$frames; | |
108 is($frame->{headers}->{'x-var'}, 'localhost', 'no data - trailer'); | |
109 is($frame->{flags}, 5, 'no data - trailer flags'); | |
110 | |
111 # CONTINUATION in response trailers | |
112 | |
113 $s = Test::Nginx::HTTP2->new(); | |
1646
5b1fa6e32549
Tests: avoid http2_max_field_size in h2_trailers.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
114 $sid = $s->new_stream({ path => '/continuation?h=' . 'x' x 4000 }); |
1194
39cfdf581253
Tests: fixed CONTINUATION test in h2_trailers.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1193
diff
changeset
|
115 $frames = $s->read(all => [{ sid => $sid, type => 'CONTINUATION' }]); |
1193 | 116 @$frames = grep { $_->{type} =~ "HEADERS|CONTINUATION|DATA" } @$frames; |
117 | |
118 is(@$frames, 4, 'continuation - frames'); | |
119 | |
120 $frame = shift @$frames; | |
121 is($frame->{headers}->{':status'}, 200, 'continuation - header'); | |
122 is($frame->{flags}, 4, 'continuation - header flags'); | |
123 | |
124 $frame = shift @$frames; | |
125 is($frame->{data}, 'SEE-THIS', 'continuation - data'); | |
126 is($frame->{flags}, 0, 'continuation - data flags'); | |
127 | |
128 $frame = shift @$frames; | |
129 is($frame->{type}, 'HEADERS', 'continuation - trailer'); | |
130 is($frame->{flags}, 1, 'continuation - trailer flags'); | |
131 | |
132 $frame = shift @$frames; | |
133 is($frame->{type}, 'CONTINUATION', 'continuation - trailer continuation'); | |
134 is($frame->{flags}, 4, 'continuation - trailer continuation flags'); | |
135 | |
136 ############################################################################### |