#16632 closed Bug (fixed)
204 (No Content) responses without content-type crashes django if UA is Internet Explorer
| Reported by: | Owned by: | Aymeric Augustin | |
|---|---|---|---|
| Component: | HTTP handling | Version: | 1.3 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
A HTTP 204 response (no content) doesn't return an entity-body in the request, but Django is forced to include a content-type header because of .../django/http/utils.py fix_IE_for_vary that expects that header to be present.
Let's say we have a HttpResponse subclass like the following:
from django.http import HttpResponse class HttpEmptyResponse(HttpResponse): """ Special HTTP reponse with no content, just headers. The content operations are ignored. """ def __init__(self, content='', mimetype=None, status=None, content_type=None): super(HttpEmptyResponse, self).__init__(status=204) # although we don't say a content-type, base class sets a # default one -- remove it, we're not returning content if 'content-type' in self._headers: del self._headers['content-type'] def _set_content(self, value): pass def _get_content(self, value): pass
Django crashes if the UA is not Internet Explorer, otherwise it works perfectly.
References:
- content-type: http://tools.ietf.org/html/rfc2616#section-7.2.1
- 204 responses: http://tools.ietf.org/html/rfc2616#section-10.2.5
Attachments (2)
Change History (8)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
| Triage Stage: | Unreviewed → Accepted |
by , 14 years ago
| Attachment: | 16632.patch added |
|---|
comment:4 by , 14 years ago
| Owner: | changed from to |
|---|
Note:
See TracTickets
for help on using tickets.
Sorry for that!