mirror of
https://github.com/django/django.git
synced 2025-10-26 15:16:09 +00:00
Fixed #11340 -- Prevented HttpResponseNotModified to have content/content-type
The HTTP 1.1 spec tells that the 304 response MUST NOT contain a message body. Thanks aparajita for the report.
This commit is contained in:
@@ -744,6 +744,16 @@ class HttpResponsePermanentRedirect(HttpResponseRedirectBase):
|
||||
class HttpResponseNotModified(HttpResponse):
|
||||
status_code = 304
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(HttpResponseNotModified, self).__init__(*args, **kwargs)
|
||||
del self['content-type']
|
||||
|
||||
@HttpResponse.content.setter
|
||||
def content(self, value):
|
||||
if value:
|
||||
raise AttributeError("You cannot set content to a 304 (Not Modified) response")
|
||||
self._container = []
|
||||
|
||||
class HttpResponseBadRequest(HttpResponse):
|
||||
status_code = 400
|
||||
|
||||
|
||||
Reference in New Issue
Block a user