feat: Add automatic charset=UTF-8 to text content types#3071
Conversation
Refactor content type handling to automatically append charset=UTF-8 to text/* MIME types when serving static files and file responses. - Add new guess_content_type() utility function that wraps mimetypes.guess_type() - Automatically append '; charset=UTF-8' to text content types - Replace direct mimetypes.guess_type() usage with new utility - Update static file serving and file() response functions to use new utility
|
Looks like tests are (still) broken. I cannot run them on my own box either without plenty of (unrelated) failures. Further work may be required on the PR, in particular with any existing tests that could've been broken by the change. |
|
I manually ran only the relevant tests because so many things fail with Sanic test server "address already in use" making the full test results unmanageable. Fixed a few issues and optimized the tests run a bit faster avoiding overlap. I note that For the sake of maintaining compatibility with prior versions, this PR does not change the |
…() interface as it is related. Removed duplicate tests, clarified naming.
Refactor content type handling to automatically append charset=UTF-8 to text/* MIME types when serving static files and file responses.
Fix #2987