﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16632	204 (No Content) responses without content-type crashes django if UA is Internet Explorer	juan@…	Aymeric Augustin	"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:

{{{
#!python

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
"	Bug	closed	HTTP handling	1.3	Normal	fixed			Accepted	1	0	0	0	0	0
