Mercurial > hg > nginx-tests
annotate h3_limit_req.t @ 1888:cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
STREAM and RESET_STREAM frames could be batched, which prevents the stream
from being processed and changes the status code. The fix is to wait for
the stream acknowledgment. Here we just look at the largest acknowledged,
this should be enough for simple cases.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 04 Apr 2023 00:33:54 +0400 |
parents | 12d950e1165c |
children | 8b74936ff2ac |
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 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; }; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 plan(skip_all => 'CryptX version >= 0.067 required') if $@; |
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 my $t = Test::Nginx->new()->has(qw/http http_v3 proxy limit_req/) |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 ->has_daemon('openssl')->plan(6); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 $t->write_file_expand('nginx.conf', <<'EOF'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 %%TEST_GLOBALS%% |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 daemon off; |
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 events { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 } |
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 http { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 %%TEST_GLOBALS_HTTP%% |
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 ssl_certificate_key localhost.key; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 ssl_certificate localhost.crt; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 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
|
48 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 log_format test $status; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 server { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 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
|
53 listen 127.0.0.1:8081; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 server_name localhost; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 location / { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 add_header X-Body $request_body; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 add_header X-Body-File $request_body_file; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 client_body_in_file_only on; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 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
|
61 limit_req zone=req burst=2; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 access_log %%TESTDIR%%/test.log test; |
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 location /stub { } |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
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 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 EOF |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 $t->write_file('openssl.conf', <<EOF); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 [ req ] |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 default_bits = 2048 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 encrypt_key = no |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 distinguished_name = req_distinguished_name |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 [ req_distinguished_name ] |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 EOF |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 my $d = $t->testdir(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 foreach my $name ('localhost') { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 system('openssl req -x509 -new ' |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 . "-config $d/openssl.conf -subj /CN=$name/ " |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 . "-out $d/$name.crt -keyout $d/$name.key " |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 . ">>$d/openssl.out 2>&1") == 0 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 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
|
87 } |
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 $t->write_file('stub', ''); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 $t->run(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
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 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 # request body delayed in limit_req |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 my $s = Test::Nginx::HTTP3->new(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 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
|
98 $s->h3_body('TEST', $sid); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 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
|
100 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 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
|
103 'request body - limit req'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 $s = Test::Nginx::HTTP3->new(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 $sid = $s->new_stream({ path => '/', body_more => 1 }); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 select undef, undef, undef, 1.1; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 $s->h3_body('TEST', $sid); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 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
|
113 'request body - limit req - limited'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 # request body with request |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 $s = Test::Nginx::HTTP3->new(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 $sid = $s->new_stream({ path => '/', body => 'TEST2' }); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 select undef, undef, undef, 1.1; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 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
|
124 'request body - limit req - with headers'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 # delayed with an empty DATA frame |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 $s = Test::Nginx::HTTP3->new(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 $sid = $s->new_stream({ path => '/', body_more => 1 }); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 $s->h3_body('', $sid); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 select undef, undef, undef, 1.1; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
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 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 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
|
136 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 # detect RESET_STREAM while request is delayed |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 $s = Test::Nginx::HTTP3->new(); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 $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
|
141 wait_ack($s); |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
142 |
1879
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 $s->reset_stream($sid, 0x010c); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 $frames = $s->read(all => [{ type => 'DECODER_C' }]); |
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 ($frame) = grep { $_->{type} eq "DECODER_C" } @$frames; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 is($frame->{'val'}, $sid, 'reset stream - cancellation'); |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 $t->stop(); |
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 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
|
152 |
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 |
1888
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
155 sub wait_ack { |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
156 my ($s) = @_; |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
157 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
|
158 |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
159 for (1 .. 5) { |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
160 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
|
161 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
|
162 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
|
163 } |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
164 } |
cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1879
diff
changeset
|
165 |
1879
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 sub read_body_file { |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 my ($path) = @_; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 return unless $path; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 open FILE, $path or return "$!"; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 local $/; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 my $content = <FILE>; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 close FILE; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 return $content; |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 } |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 |
12d950e1165c
Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 ############################################################################### |