diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-08-22 18:06:03 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-08-22 20:55:24 +0200 |
| commit | 7cfe8e8fce7677ec696f42a7d1501a97e8191a3d (patch) | |
| tree | 1d751731d3c996ba8f6cdeee097300bbff3de51f /django/http/__init__.py | |
| parent | e2b4eddc11b391bc0047032776e9ca7c2f9328b3 (diff) | |
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.
Diffstat (limited to 'django/http/__init__.py')
| -rw-r--r-- | django/http/__init__.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py index 701e76f7fa..7782ebe648 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -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 |
