Don't include CONTENT_TYPE/CONTENT_LENGTH in environ if absent in headers #1308
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This has been reported earlier in #1049 and #1159, but closed since it's valid behavior according to the WSGI spec. It is however inconsistent with how most of the wsgi servers handle it.
With the following test application I tested this for gunicorn, gevent, twisted and uwsgi:
gunicorn test_app
gevent.WSGIServer.serve_forever()
twistd -n web test_app.application
uwsgi --http :8000 --wsgi-file test_app.py
Of the four tested, only Twisted handles the environ the way werkzeug does, the others will experience inconsistencies between their test and production environments.
We had trouble reproducing a production error in test because of this as it's currently non-trivial to test a missing content-type header in flask. If absent by default it's easy to test both absent and empty header values, as you can send an empty string in the headers to get the old behavior.