Mercurial > hg > nginx-tests
annotate h3_limit_req.t @ 1951:1867428f1673
Tests: fixed h3_limit_req.t spurious failures.
In the "reset stream - cancellation" test, HTTP/3 stream is closed without
sending the request body when the request is waiting in the limit_req
module, and this results in error 444. However, when the request is received
with some minor delay due to system load, it is not delayed by limit_req,
and the stream is closed during reading the request body, which results
in error 400 instead, breaking the test.
Fix is to introduce yet another request before the "reset stream" test,
so the stream in question is always delayed by limit_req.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 14 Mar 2024 02:25:49 +0300 |
parents | 8b74936ff2ac |
children |
rev | line source |
---|---|
1879
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for HTTP/3 protocol with limit_req. |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP3; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
1896
8b74936ff2ac
Tests: added has_feature() test for CryptX.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1888
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v3 proxy limit_req cryptx/) |
1951
1867428f1673
Tests: fixed h3_limit_req.t spurious failures.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
27 ->has_daemon('openssl')->plan(7); |
1879
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 $t->write_file_expand('nginx.conf', <<'EOF'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 ssl_certificate_key localhost.key; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 ssl_certificate localhost.crt; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 limit_req_zone $binary_remote_addr zone=req:1m rate=1r/s; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 log_format test $status; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 server { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 listen 127.0.0.1:%%PORT_8980_UDP%% quic; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 listen 127.0.0.1:8081; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 server_name localhost; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 location / { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 add_header X-Body $request_body; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 add_header X-Body-File $request_body_file; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 client_body_in_file_only on; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 proxy_pass http://127.0.0.1:8081/stub; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 limit_req zone=req burst=2; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 access_log %%TESTDIR%%/test.log test; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 } |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 location /stub { } |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 } |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 } |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 EOF |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 $t->write_file('openssl.conf', <<EOF); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 [ req ] |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 default_bits = 2048 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 encrypt_key = no |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 distinguished_name = req_distinguished_name |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 [ req_distinguished_name ] |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 EOF |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 my $d = $t->testdir(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 foreach my $name ('localhost') { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 system('openssl req -x509 -new ' |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 . "-config $d/openssl.conf -subj /CN=$name/ " |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 . "-out $d/$name.crt -keyout $d/$name.key " |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 . ">>$d/openssl.out 2>&1") == 0 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 or die "Can't create certificate for $name: $!\n"; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 } |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 $t->write_file('stub', ''); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 $t->run(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 ############################################################################### |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 # request body delayed in limit_req |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 my $s = Test::Nginx::HTTP3->new(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 my $sid = $s->new_stream({ path => '/', body_more => 1 }); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 $s->h3_body('TEST', $sid); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 is(read_body_file($frame->{headers}->{'x-body-file'}), 'TEST', |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 'request body - limit req'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 $s = Test::Nginx::HTTP3->new(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 $sid = $s->new_stream({ path => '/', body_more => 1 }); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 select undef, undef, undef, 1.1; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 $s->h3_body('TEST', $sid); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 is(read_body_file($frame->{headers}->{'x-body-file'}), 'TEST', |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 'request body - limit req - limited'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 # request body with request |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 $s = Test::Nginx::HTTP3->new(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 $sid = $s->new_stream({ path => '/', body => 'TEST2' }); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 select undef, undef, undef, 1.1; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 is(read_body_file($frame->{headers}->{'x-body-file'}), 'TEST2', |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 'request body - limit req - with headers'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 # delayed with an empty DATA frame |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 $s = Test::Nginx::HTTP3->new(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 $sid = $s->new_stream({ path => '/', body_more => 1 }); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 $s->h3_body('', $sid); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 select undef, undef, undef, 1.1; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 is($frame->{headers}->{':status'}, 200, 'request body - limit req - empty'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 |
1951
1867428f1673
Tests: fixed h3_limit_req.t spurious failures.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
134 # another request |
1867428f1673
Tests: fixed h3_limit_req.t spurious failures.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
135 |
1867428f1673
Tests: fixed h3_limit_req.t spurious failures.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
136 $sid = $s->new_stream({ path => '/' }); |
1867428f1673
Tests: fixed h3_limit_req.t spurious failures.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
137 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
1867428f1673
Tests: fixed h3_limit_req.t spurious failures.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
138 |
1867428f1673
Tests: fixed h3_limit_req.t spurious failures.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
139 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
1867428f1673
Tests: fixed h3_limit_req.t spurious failures.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
140 is($frame->{headers}->{':status'}, '200', 'request body - limit req - next'); |
1867428f1673
Tests: fixed h3_limit_req.t spurious failures.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
141 |
1879
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 # detect RESET_STREAM while request is delayed |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 $s = Test::Nginx::HTTP3->new(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 $sid = $s->new_stream({ path => '/', body_more => 1 }); |
1888
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
146 wait_ack($s); |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
147 |
1879
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 $s->reset_stream($sid, 0x010c); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 $frames = $s->read(all => [{ type => 'DECODER_C' }]); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 ($frame) = grep { $_->{type} eq "DECODER_C" } @$frames; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 is($frame->{'val'}, $sid, 'reset stream - cancellation'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 $t->stop(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 like($t->read_file('test.log'), qr/499/, 'reset stream - log'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 ############################################################################### |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 |
1888
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
160 sub wait_ack { |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
161 my ($s) = @_; |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
162 my $last = $s->{pn}[0][3]; |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
163 |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
164 for (1 .. 5) { |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
165 my $frames = $s->read(all => [ {type => 'ACK' }]); |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
166 my ($frame) = grep { $_->{type} eq "ACK" } @$frames; |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
167 last unless $frame->{largest} < $last; |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
168 } |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
169 } |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
170 |
1879
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 sub read_body_file { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 my ($path) = @_; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 return unless $path; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 open FILE, $path or return "$!"; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 local $/; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 my $content = <FILE>; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 close FILE; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 return $content; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 } |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 ############################################################################### |