Don't rely on X-Requested-With for pretty print json response (#2193)

* Don't rely on X-Requested-With for pretty print json response

* Fix test cases for pretty print json patch

* Fix gramma error in docs for pretty print json config

* Add changelog for JSONIFY_PRETTYPRINT_REGULAR
This commit is contained in:
Hsiaoming Yang 2017-03-07 10:09:46 +09:00 committed by GitHub
parent f5adb61b28
commit a7f1a21c12
6 changed files with 11 additions and 8 deletions

View file

@ -314,7 +314,7 @@ class Flask(_PackageBoundObject):
'PREFERRED_URL_SCHEME': 'http',
'JSON_AS_ASCII': True,
'JSON_SORT_KEYS': True,
'JSONIFY_PRETTYPRINT_REGULAR': True,
'JSONIFY_PRETTYPRINT_REGULAR': False,
'JSONIFY_MIMETYPE': 'application/json',
'TEMPLATES_AUTO_RELOAD': None,
})

View file

@ -248,7 +248,7 @@ def jsonify(*args, **kwargs):
indent = None
separators = (',', ':')
if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:
if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] or current_app.debug:
indent = 2
separators = (', ', ': ')