Skip to content

Commit 70f490e

Browse files
committed
Tests: discarded request body in error_page redirect.
1 parent 284799c commit 70f490e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

body.t

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use Test::Nginx;
2222
select STDERR; $| = 1;
2323
select STDOUT; $| = 1;
2424

25-
my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(14);
25+
my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(15);
2626

2727
$t->write_file_expand('nginx.conf', <<'EOF');
2828
@@ -81,6 +81,9 @@ http {
8181
location /next {
8282
proxy_pass http://u/;
8383
}
84+
location /redirect {
85+
error_page 404 http://example.com/;
86+
}
8487
}
8588
8689
server {
@@ -165,6 +168,24 @@ like(
165168
like(http_get_body('/next', '0123456789'),
166169
qr/X-Body: 0123456789\x0d?$/ms, 'body next upstream');
167170

171+
# discarded request body in redirect via error_page
172+
173+
TODO: {
174+
local $TODO = 'not yet' unless $t->has_version('1.17.7');
175+
176+
unlike(
177+
http(
178+
'POST /redirect HTTP/1.1' . CRLF
179+
. 'Host: localhost' . CRLF
180+
. 'Content-Length: 10' . CRLF . CRLF
181+
. '0123456789' .
182+
'GET /next HTTP/1.0' . CRLF . CRLF
183+
),
184+
qr/400 Bad Request/ms, 'redirect - discard request body'
185+
);
186+
187+
}
188+
168189
###############################################################################
169190

170191
sub read_body_file {

0 commit comments

Comments
 (0)