#34404: Incorrect documentation about content type set by FileResponse object
-----------------------------------------+------------------------
Reporter: chamalsl | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 4.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/34404>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070186ce9387d4-1c57df27-ee15-4a15-a8d3-b07ea1efe133-000000%40eu-central-1.amazonses.com.