问题
It seems uwsgi remembers headers from a previous request in async mode!
I deployed a very simple application with uwsgi:
and ran it with:
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
environ_repr = '\n'.join(sorted(key.ljust(30) + ' = ' + repr(value) for key, value in environ.items()))
return [environ_repr]
Steps to regenerate the problem:uwsgi --module index -s 0.0.0.0:8000 -p 1 --async 5
- Visit 127.0.0.1:8000 with header "Key: Value", there is
HTTP_KEY
entry inenvironment
, OK. - Now, visit 127.0.0.1:8000 without that header, but
HTTP_KEY
entry still is presentenvironment
, oopch!
Note: Same thing happens with other headers like Cookie
!
(Tested with uwsgi 1.0, 1.2.4 and 1.3-dev, and python 2.7)
回答1:
There was a bug in uwsgi and fixed in:
https://github.com/unbit/uwsgi/commit/e393f36f0adbdb49e4a84098865bb6e3c01785e4
来源:https://stackoverflow.com/questions/11598935/uwsgi-resends-headers-in-async-mode