summaryrefslogtreecommitdiff
path: root/django/http
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-12-30 15:19:22 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-12-31 12:49:10 +0100
commitfd1279a44df3b9a837453cd79fd0fbcf81bae39d (patch)
tree1323829d8630fb55acabed516c0a7149574b11fc /django/http
parentac72782e61a8e08381cb66005295a4c24ed37f33 (diff)
[1.5.x] Fixed #19519 -- Fired request_finished in the WSGI iterable's close().
Backport of acc5396.
Diffstat (limited to 'django/http')
-rw-r--r--django/http/response.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/django/http/response.py b/django/http/response.py
index df0a955b18..46cb88751b 100644
--- a/django/http/response.py
+++ b/django/http/response.py
@@ -10,6 +10,7 @@ except ImportError:
from urlparse import urlparse
from django.conf import settings
+from django.core import signals
from django.core import signing
from django.core.exceptions import SuspiciousOperation
from django.http.cookie import SimpleCookie
@@ -40,6 +41,9 @@ class HttpResponseBase(six.Iterator):
self._headers = {}
self._charset = settings.DEFAULT_CHARSET
self._closable_objects = []
+ # This parameter is set by the handler. It's necessary to preserve the
+ # historical behavior of request_finished.
+ self._handler_class = None
if mimetype:
warnings.warn("Using mimetype keyword argument is deprecated, use"
" content_type instead", PendingDeprecationWarning)
@@ -225,7 +229,11 @@ class HttpResponseBase(six.Iterator):
# See http://blog.dscpl.com.au/2012/10/obligations-for-calling-close-on.html
def close(self):
for closable in self._closable_objects:
- closable.close()
+ try:
+ closable.close()
+ except Exception:
+ pass
+ signals.request_finished.send(sender=self._handler_class)
def write(self, content):
raise Exception("This %s instance is not writable" % self.__class__.__name__)