$request_body bug?
agentzh
agentzh at gmail.com
Fri Oct 23 05:46:50 MSD 2009
On Thu, Oct 22, 2009 at 3:57 PM, agentzh <agentzh at gmail.com> wrote:
>
> The $request_body variable only has values when the underlying content
> handler or upstream handler or anything else has actually *read* the
> request body from the tcp connection and stored it into
> r->request_body slot.
>
Sorry, forgot to mention that for POST data that has well exceeded
"client_body_buffer_size", Nginx will write the data into temporary
files on the disk. In this case, the $request_body variable is also
evaluated to an empty string ("").
To help demonstrating this, I've added the "read_request_body"
directive to my "echo" module (released as v0.14), which calls the
"ngx_http_read_client_request_body" function, just as the "proxy"
module and many others. The following example clearly shows the
situation described above.
In the nginx.conf:
location /echobody {
client_body_buffer_size 2;
echo_read_request_body;
echo $request_body;
}
On the client side:
$ perl -e 'print "a"x2' | lwp-request -m POST 'http://localhost:8080/echobody'
aa
$ perl -e 'print "a"x1024' | lwp-request -m POST
'http://localhost:8080/echobody'
As we can see, the second request feeds 1KB POST request body, well
above the 2 bytes "client_body_buffer_size" setting and $request_body
yields empty.
I'm guessing this is more likely in your situation but I could be wrong :)
Cheers,
-agentzh
More information about the nginx
mailing list