I’ve come across an incredibly weird problem with POST responses using
nginx 1.0.1 and uWSGI 0.9.7.2 on CentOS 5.6.
uWSGI successfully sends the response body to nginx, but nginx seems to
ignore it if both (1) the request method is POST, and (2) the response
length is less than 4052 bytes. The issue doesn’t occur when serving
directly using uwsgi --http, so I’m pretty sure the problem is
something to do with nginx.
To explain things in code, this Python results in the desired response:
Thanks, that helped point me to the issue. It turns out the problem was
that I didn’t pass --pep3333-input to uWSGI, so it was converting all
CRLFs to LFs in the request body, so CONTENT_LENGTH didn’t match the
data length. Passing that flag to uWSGI made it pass the raw stream to
my app and solved the problem.
Be sure to read POST body in your WSGI app if Content-Length > 0,
otherwise your socket queue will get clobbered (nginx will receive a
close
when there is still data available in the queue)