Nginx/uWSGI bug – empty post response
It turns out that in certain situations (which I haven’t investigated thoroughly enough, sorry), nginx/uWSGI drop the post response body! The fix appears to be to read the content of the post request (I came across this solution on StackOverflow). Something like this (using flask):
@app.route("/", methods=["POST"])
def my_postable():
not_used = request.data # Very strange bug with uWSGI/nginx - unless you read the
# post data, the server returns a blank response!
return render_template('my_postable_template.html')
That, from a general point of view, is the right behaviour (for nginx), as closing a socket without reading available data from it, is wrong. Throwing away what is already read (by nginx) could be avoided, but for technical reasons they prefer to throw away invalid sessions (that is why you will not find such behaviour on other proxy/webserver). By the way, uWSGI has an option for avoiding you to have to install a (slow) middleware. Check –post-buffering, and more generally check http://uwsgi-docs.readthedocs.org/en/latest/ThingsToKnow.html that is a collection of “unexpected” behaviours.
Thank you very much for the information! The link you supplied is also very enlightening.