annotate h3_limit_req.t @ 1879:12d950e1165c

Tests: HTTP/3 tests with limit_req.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 12 Jan 2023 20:53:50 +0400
parents
children cc13f7b098db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 });
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
141 $s->reset_stream($sid, 0x010c);
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142 $frames = $s->read(all => [{ type => 'DECODER_C' }]);
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 ($frame) = grep { $_->{type} eq "DECODER_C" } @$frames;
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145 is($frame->{'val'}, $sid, 'reset stream - cancellation');
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 $t->stop();
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 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
150
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 ###############################################################################
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 sub read_body_file {
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
154 my ($path) = @_;
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
155 return unless $path;
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
156 open FILE, $path or return "$!";
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
157 local $/;
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
158 my $content = <FILE>;
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
159 close FILE;
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
160 return $content;
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
161 }
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
162
12d950e1165c Tests: HTTP/3 tests with limit_req.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
163 ###############################################################################