# HG changeset patch # User Maxim Dounin # Date 1363793507 -14400 # Node ID 1a6eef7ac9141d71b8d42fe88f71452ec7c224b8 # Parent f857180657c9c69e45e5814e79f4f1e13a3c19a4 Tests: test for r->request_body->buf incorrect reuse. diff --git a/body.t b/body.t --- a/body.t +++ b/body.t @@ -22,7 +22,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(12); +my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(13); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -62,6 +62,7 @@ http { } location /small { client_body_in_file_only on; + add_header X-Original-Uri "$request_uri"; proxy_pass http://127.0.0.1:8080/; } location /single { @@ -139,6 +140,20 @@ like(http_get_body('/discard', '01234567 like(http_get_body('/small', '0123456789'), qr/X-Body: 0123456789\x0d?$/ms, 'small body in file only'); +# proxy with file only - reuse of r->header_in + +like( + http( + 'GET /small HTTP/1.0' . CRLF + . 'Content-Length: 10' . CRLF . CRLF + . '01234', + sleep => 0.1, + body => '56789' + ), + qr!X-Body: 0123456789\x0d?\x0a.*X-Original-Uri: /small!ms, + 'small body in file only, not preread' +); + # proxy_next_upstream like(http_get_body('/next', '0123456789'), diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm --- a/lib/Test/Nginx.pm +++ b/lib/Test/Nginx.pm @@ -420,6 +420,11 @@ sub http($;%) { select undef, undef, undef, $extra{sleep} if $extra{sleep}; return '' if $extra{aborted}; + if ($extra{body}) { + log_out($extra{body}); + $s->print($extra{body}); + } + local $/; $reply = $s->getline();