Skip to content
Myr

Second thoughts on mime type

Before adoption: this commit came in with the history the project adopted, so no landing records it.

After further review, changing the mime type on jsonp responses from text/javascript to application/javascript, with a hat-tip to http://stackoverflow.com/questions/111302/best-content-type-to-serve-jsonp

authored by Ned Jackson Lovely · committed by Ned Jackson Lovely · parent 27194a0 · Browse files · 1 file+2 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−2 removed

  • other:+2 added−2 removed

1 file+2 added−2 removed

modified:flask/helpers.py+2 added-2 removed
119 unmodified lines
120121 .. versionadded:: 0.9122 If the ``padded`` argument is true, the JSON object will be padded123 for JSONP calls and the response mimetype will be changed to 124 ``text/javascript``. By default, the request arguments ``callback``124 ``application/javascript``. By default, the request arguments ``callback``125 and ``jsonp`` will be used as the name for the callback function.126 This will work with jQuery and most other JavaScript libraries127 by default.128
11 unmodified lines
140 request.args.get('jsonp') or 'jsonp'141 del kwargs['padded']142 json_str = json.dumps(dict(*args, **kwargs), indent=None)143 content = str(callback) + "(" + json_str + ")"144 return current_app.response_class(content, mimetype='text/javascript')144 return current_app.response_class(content, mimetype='application/javascript')145 return current_app.response_class(json.dumps(dict(*args, **kwargs),146 indent=None if request.is_xhr else 2), mimetype='application/json')147148
562 unmodified lines