Ticket #508 (defect)
Opened 3 years ago
Last modified 2 years ago
304s generated via HTTPRedirect() should not set Content-Type
Status: closed (fixed)
| Reported by: | lukem | Assigned to: | rdelon |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | CherryPy code | Keywords: | 304 httpredirect content-type |
| Cc: |
Since 304s do not (and must not) return a message body, it is inappropriate for them to set the Content-Type header. The current implementation always sets 304 Content-Type to text/html, which is especially bad for for non-html resources.
To fix, just move the cherrypy.response.headerMap['Content-Type'] = "text/html" line into the if status in (300, 301, 302, 303, 307): block in cherrypy/_cperror.py.


Hmm, perhaps a del cherrypy.response.headerMap['Content-Type'] would be more appropriate, as there seems to be a default Content-Type header set by the Request object's constructor.