Mercurial > hg > nginx-tests
annotate h3_request_body_discard.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | fe6f22da53ec |
children |
rev | line source |
---|---|
1961
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for discarding request body with HTTP/3. |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 use Socket qw/ CRLF /; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use lib 'lib'; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 use Test::Nginx; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP3; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 ############################################################################### |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new() |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 ->has(qw/http http_v3 proxy rewrite addition memcached cryptx/) |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 ->has_daemon('openssl'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 plan(skip_all => 'not yet') unless $t->has_version('1.27.0'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 $t->plan(37)->write_file_expand('nginx.conf', <<'EOF'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 %%TEST_GLOBALS%% |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 daemon off; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 events { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 http { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 %%TEST_GLOBALS_HTTP%% |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 ssl_certificate localhost.crt; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 ssl_certificate_key localhost.key; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 server { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 listen 127.0.0.1:%%PORT_8980_UDP%% quic; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 server_name localhost; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 lingering_timeout 1s; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 add_header X-Body body:$content_length:$request_body:; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 client_max_body_size 1k; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 location / { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 error_page 413 /error413; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 proxy_pass http://127.0.0.1:8082; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 location /error413 { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 return 200 "custom error 413"; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 location /add { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 return 200 "main response"; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 add_before_body /add/before; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 addition_types *; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 client_max_body_size 1m; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 location /add/before { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 proxy_pass http://127.0.0.1:8081; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 location /memcached { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 client_max_body_size 1m; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 error_page 502 /memcached/error502; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 memcached_pass 127.0.0.1:8083; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 set $memcached_key $request_uri; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 location /memcached/error502 { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 proxy_pass http://127.0.0.1:8081; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 location /proxy { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 client_max_body_size 3; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 error_page 413 /proxy/error413; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 error_page 400 /proxy/error400; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 error_page 502 /proxy/error502; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 proxy_pass http://127.0.0.1:8083; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 location /proxy/error413 { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 proxy_pass http://127.0.0.1:8081; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 location /proxy/error400 { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 proxy_pass http://127.0.0.1:8081; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 location /proxy/error502 { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 proxy_pass http://127.0.0.1:8081; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 location /unbuf { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 client_max_body_size 1m; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 error_page 502 /unbuf/error502; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 proxy_pass http://127.0.0.1:8083; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 proxy_request_buffering off; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 proxy_http_version 1.1; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 location /unbuf/error502 { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 client_max_body_size 1m; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 proxy_pass http://127.0.0.1:8081; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 location /unbuf2 { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 client_max_body_size 1m; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 error_page 400 /unbuf2/error400; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 proxy_pass http://127.0.0.1:8081; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 proxy_request_buffering off; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 proxy_http_version 1.1; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 location /unbuf2/error400 { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 client_max_body_size 1m; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 proxy_pass http://127.0.0.1:8081; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 location /length { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 client_max_body_size 1; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 error_page 413 /length/error413; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 error_page 502 /length/error502; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 proxy_pass http://127.0.0.1:8083; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 location /length/error413 { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 return 200 "frontend body:$content_length:$request_body:"; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 location /length/error502 { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 return 200 "frontend body:$content_length:$request_body:"; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 server { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 listen 127.0.0.1:8081; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 server_name localhost; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 location / { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 proxy_pass http://127.0.0.1:8082; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 proxy_set_header X-Body body:$content_length:$request_body:; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 server { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 listen 127.0.0.1:8082; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 server_name localhost; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 return 200 "backend $http_x_body"; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
165 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
166 server { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
167 listen 127.0.0.1:8083; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
168 server_name localhost; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
169 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 return 444; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
172 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
173 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
174 EOF |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
176 $t->write_file('openssl.conf', <<EOF); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
177 [ req ] |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 default_bits = 2048 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 encrypt_key = no |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
180 distinguished_name = req_distinguished_name |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
181 [ req_distinguished_name ] |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
182 EOF |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
184 my $d = $t->testdir(); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
185 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
186 foreach my $name ('localhost') { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
187 system('openssl req -x509 -new ' |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
188 . "-config $d/openssl.conf -subj /CN=$name/ " |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
189 . "-out $d/$name.crt -keyout $d/$name.key " |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
190 . ">>$d/openssl.out 2>&1") == 0 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
191 or die "Can't create certificate for $name: $!\n"; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
192 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
193 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 $t->run(); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
196 ############################################################################### |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
197 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
198 # error_page 413 should work without redefining client_max_body_size |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
199 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
200 like(http3_get_body('/', '0123456789' x 128), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
201 qr/status: 413.*custom error 413/s, 'custom error 413'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
202 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
203 # subrequest after discarding body |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
204 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
205 like(http3_get('/add'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
206 qr/backend body:::.*main response/s, 'add'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
207 like(http3_get_body('/add', '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
208 qr/backend body:::.*main response/s, 'add small'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
209 like(http3_get_body_incomplete('/add', 10000, '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
210 qr/backend body:::.*main response/s, 'add long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
211 like(http3_get_body_nolen('/add', '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
212 qr/backend body:::.*main response/s, 'add nolen'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
213 like(http3_get_body_nolen('/add', '0', '123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
214 qr/backend body:::.*main response/s, 'add nolen multi'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
215 like(http3_get_body_incomplete_nolen('/add', 10000, '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
216 qr/backend body:::.*main response/s, 'add chunked long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
217 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
218 # error_page 502 with proxy_pass after discarding body |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
219 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
220 like(http3_get('/memcached'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
221 qr/backend body:::/s, 'memcached'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
222 like(http3_get_body('/memcached', '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
223 qr/status: 502.*backend body:::/s, 'memcached small'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
224 like(http3_get_body_incomplete('/memcached', 10000, '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
225 qr/status: 502.*backend body:::/s, 'memcached long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
226 like(http3_get_body_nolen('/memcached', '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
227 qr/status: 502.*backend body:::/s, 'memcached nolen'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
228 like(http3_get_body_nolen('/memcached', '0', '123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
229 qr/status: 502.*backend body:::/s, 'memcached nolen multi'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
230 like(http3_get_body_incomplete_nolen('/memcached', 10000, '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
231 qr/status: 502.*backend body:::/s, 'memcached nolen long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
232 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
233 # error_page 413 with proxy_pass |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
234 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
235 like(http3_get('/proxy'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
236 qr/status: 502.*backend body:::/s, 'proxy'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
237 like(http3_get_body('/proxy', '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
238 qr/status: 413.*backend body:::/s, 'proxy small'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
239 like(http3_get_body_incomplete('/proxy', 10000, '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
240 qr/status: 413.*backend body:::/s, 'proxy long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
241 like(http3_get_body_nolen('/proxy', '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
242 qr/status: 413.*backend body:::/s, 'proxy nolen'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
243 like(http3_get_body_nolen('/proxy', '0', '123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
244 qr/status: 413.*backend body:::/s, 'proxy nolen multi'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
245 like(http3_get_body_incomplete_nolen('/proxy', '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
246 qr/status: 413.*backend body:::/s, 'proxy nolen long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
247 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
248 # error_page 400 with proxy_pass |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
249 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
250 like(http3_get_body_custom('/proxy', 1, ''), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
251 qr/status: 400.*backend body:::/s, 'proxy too short'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
252 like(http3_get_body_custom('/proxy', 1, '01'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
253 qr/status: 400.*backend body:::/s, 'proxy too long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
254 like(http3_get_body_custom('/proxy', 1, '01', more => 1), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
255 qr/status: 400.*backend body:::/s, 'proxy too long more'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
256 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
257 # error_page 502 after proxy with request buffering disabled |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
258 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
259 like(http3_get('/unbuf'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
260 qr/status: 502.*backend body:::/s, 'unbuf proxy'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
261 like(http3_get_body_custom('/unbuf', 10, '0123456789', sleep => 0.1), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
262 qr/status: 502.*backend body:::/s, 'unbuf proxy small'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
263 like(http3_get_body_incomplete('/unbuf', 10000, '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
264 qr/status: 502.*backend body:::/s, 'unbuf proxy long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
265 like(http3_get_body_nolen('/unbuf', '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
266 qr/status: 502.*backend body:::/s, 'unbuf proxy nolen'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
267 like(http3_get_body_nolen('/unbuf', '0', '123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
268 qr/status: 502.*backend body:::/s, 'unbuf proxy nolen multi'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
269 like(http3_get_body_incomplete_nolen('/unbuf', 10000, '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
270 qr/status: 502.*backend body:::/s, 'unbuf proxy nolen long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
271 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
272 # error_page 400 after proxy with request buffering disabled |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
273 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
274 like(http3_get_body_custom('/unbuf2', 1, '', sleep => 0.1), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
275 qr/status: 400.*backend body:::/s, 'unbuf too short'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
276 like(http3_get_body_custom('/unbuf2', 1, '01', sleep => 0.1), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
277 qr/status: 400.*backend body:::/s, 'unbuf too long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
278 like(http3_get_body_custom('/unbuf2', 1, '01', sleep => 0.1, more => 1), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
279 qr/status: 400.*backend body:::/s, 'unbuf too long more'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
280 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
281 # error_page 413 and $content_length |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
282 # (used in fastcgi_pass, grpc_pass, uwsgi_pass) |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
283 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
284 like(http3_get('/length'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
285 qr/status: 502.*frontend body:::/s, '$content_length'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
286 like(http3_get_body('/length', '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
287 qr/status: 413.*frontend body:::/s, '$content_length small'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
288 like(http3_get_body_incomplete('/length', 10000, '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
289 qr/status: 413.*frontend body:::/s, '$content_length long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
290 like(http3_get_body_nolen('/length', '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
291 qr/status: 413.*frontend body:::/s, '$content_length nolen'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
292 like(http3_get_body_nolen('/length', '0', '123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
293 qr/status: 413.*frontend body:::/s, '$content_length nolen multi'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
294 like(http3_get_body_incomplete_nolen('/length', 10000, '0123456789'), |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
295 qr/status: 413.*frontend body:::/s, '$content_length nolen long'); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
296 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
297 ############################################################################### |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
298 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
299 sub http3_get { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
300 my ($uri) = @_; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
301 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
302 my $s = Test::Nginx::HTTP3->new(); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
303 my $sid = $s->new_stream({ path => $uri }); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
304 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
305 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
306 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
307 my (@data) = grep { $_->{type} eq "DATA" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
308 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
309 return join("\n", map { "$_: " . $frame->{headers}->{$_}; } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
310 keys %{$frame->{headers}}) . "\n\n" |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
311 . join("", map { $_->{data} } @data); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
312 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
313 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
314 sub http3_get_body { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
315 my ($uri, $body) = @_; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
316 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
317 my $s = Test::Nginx::HTTP3->new(); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
318 my $sid = $s->new_stream({ path => $uri, body => $body }); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
319 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
320 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
321 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
322 my (@data) = grep { $_->{type} eq "DATA" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
323 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
324 return join("\n", map { "$_: " . $frame->{headers}->{$_}; } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
325 keys %{$frame->{headers}}) . "\n\n" |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
326 . join("", map { $_->{data} } @data); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
327 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
328 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
329 sub http3_get_body_nolen { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
330 my ($uri, $body, $body2) = @_; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
331 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
332 my $s = Test::Nginx::HTTP3->new(); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
333 my $sid = $s->new_stream({ path => $uri, body_more => 1 }); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
334 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
335 if (defined $body2) { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
336 select undef, undef, undef, 0.1; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
337 $s->h3_body($body, $sid, { body_more => 1 }); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
338 select undef, undef, undef, 0.1; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
339 $s->h3_body($body2, $sid); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
340 } else { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
341 select undef, undef, undef, 0.1; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
342 $s->h3_body($body, $sid); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
343 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
344 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
345 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
346 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
347 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
348 my (@data) = grep { $_->{type} eq "DATA" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
349 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
350 return join("\n", map { "$_: " . $frame->{headers}->{$_}; } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
351 keys %{$frame->{headers}}) . "\n\n" |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
352 . join("", map { $_->{data} } @data); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
353 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
354 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
355 sub http3_get_body_incomplete { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
356 my ($uri, $len, $body) = @_; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
357 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
358 my $s = Test::Nginx::HTTP3->new(); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
359 my $sid = $s->new_stream({ |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
360 headers => [ |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
361 { name => ':method', value => 'GET' }, |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
362 { name => ':scheme', value => 'http' }, |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
363 { name => ':path', value => $uri }, |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
364 { name => ':authority', value => 'localhost' }, |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
365 { name => 'content-length', value => $len }, |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
366 ], |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
367 body_more => 1 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
368 }); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
369 $s->h3_body($body, $sid, { body_more => 1 }); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
370 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
371 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
372 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
373 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
374 my (@data) = grep { $_->{type} eq "DATA" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
375 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
376 return join("\n", map { "$_: " . $frame->{headers}->{$_}; } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
377 keys %{$frame->{headers}}) . "\n\n" |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
378 . join("", map { $_->{data} } @data); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
379 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
380 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
381 sub http3_get_body_incomplete_nolen { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
382 my ($uri, $body) = @_; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
383 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
384 my $s = Test::Nginx::HTTP3->new(); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
385 my $sid = $s->new_stream({ path => $uri, body_more => 1 }); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
386 $s->h3_body($body, $sid, { body_more => 1 }); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
387 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
388 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
389 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
390 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
391 my (@data) = grep { $_->{type} eq "DATA" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
392 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
393 return join("\n", map { "$_: " . $frame->{headers}->{$_}; } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
394 keys %{$frame->{headers}}) . "\n\n" |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
395 . join("", map { $_->{data} } @data); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
396 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
397 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
398 sub http3_get_body_custom { |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
399 my ($uri, $len, $body, %extra) = @_; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
400 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
401 my $s = Test::Nginx::HTTP3->new(); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
402 my $sid = $s->new_stream({ |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
403 headers => [ |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
404 { name => ':method', value => 'GET' }, |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
405 { name => ':scheme', value => 'http' }, |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
406 { name => ':path', value => $uri }, |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
407 { name => ':authority', value => 'localhost' }, |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
408 { name => 'content-length', value => $len }, |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
409 ], |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
410 body_more => 1 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
411 }); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
412 select undef, undef, undef, $extra{sleep} if $extra{sleep}; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
413 $s->h3_body($body, $sid, { body_more => 1 }); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
414 $s->h3_body('', $sid) unless $extra{more}; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
415 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
416 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
417 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
418 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
419 my (@data) = grep { $_->{type} eq "DATA" } @$frames; |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
420 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
421 return join("\n", map { "$_: " . $frame->{headers}->{$_}; } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
422 keys %{$frame->{headers}}) . "\n\n" |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
423 . join("", map { $_->{data} } @data); |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
424 } |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
425 |
fe6f22da53ec
Tests: tests for usage of discarded body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
426 ############################################################################### |