Mercurial > hg > nginx-tests
annotate h3_limit_req.t @ 1905:f35824e75b66
Tests: fixed reading QUIC streams on Perl < 5.24.
The parse_stream() routine has had a missing explicit return if there were no
streams received. In Perl < 5.24 this used to return no value, or an empty
array in the list context. In modern Perl this returns an empty value, or an
array of 1 element, which made the check for last index of the returned array
work rather by accident.
The fix is to return explicitly and to check the array size in callers instead.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 06 Jun 2023 18:50:07 +0400 |
parents | 8b74936ff2ac |
children | 1867428f1673 |
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/) |
1879
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 ->has_daemon('openssl')->plan(6); |
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 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 # detect RESET_STREAM while request is delayed |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 $s = Test::Nginx::HTTP3->new(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 $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
|
138 wait_ack($s); |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
139 |
1879
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 $s->reset_stream($sid, 0x010c); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 $frames = $s->read(all => [{ type => 'DECODER_C' }]); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 ($frame) = grep { $_->{type} eq "DECODER_C" } @$frames; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 is($frame->{'val'}, $sid, 'reset stream - cancellation'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 $t->stop(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 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
|
149 |
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 |
1888
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
152 sub wait_ack { |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
153 my ($s) = @_; |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
154 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
|
155 |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
156 for (1 .. 5) { |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
157 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
|
158 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
|
159 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
|
160 } |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
161 } |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
162 |
1879
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 sub read_body_file { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 my ($path) = @_; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 return unless $path; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 open FILE, $path or return "$!"; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 local $/; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 my $content = <FILE>; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 close FILE; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 return $content; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 } |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 ############################################################################### |