#34404 closed Cleanup/optimization (fixed)
Incorrect documentation about content type set by FileResponse object
Reported by: | chamalsl | Owned by: | Ayush Bisht |
---|---|---|---|
Component: | Documentation | Version: | 4.1 |
Severity: | Normal | Keywords: | |
Cc: | chamalsl | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
Below is an excerpt from the Django document for FileResponse object.
Link: https://docs.djangoproject.com/en/4.1/ref/request-response/
"The Content-Length and Content-Type headers are automatically set when they can be guessed from contents of open_file".
But code inside FileResponse object does not use contents of open_file to guess content type.
It uses "mimetypes.guess_type()" method to determine content type.
"mimetypes.guess_type()" method uses file extension to to determine content type.
So a file response object such as this will set the content type to "text/html".
FileResponse(open('test.gif', 'rb'), filename="test.html")
Documentation should correctly mention how FileResponse object determine content type.
Change History (7)
comment:1 by , 22 months ago
Cc: | added |
---|
comment:2 by , 22 months ago
Description: | modified (diff) |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
comment:3 by , 22 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 22 months ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Thanks for the report.