From c3d7aad6d0911bb84120d7c8d41923c895784b21 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 22 Sep 2006 12:32:00 +0000 Subject: Fixed #2560 -- Add close() support to HttpResponse iterators. Thanks, Ivan Sagalaev. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3791 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/handlers/modpython.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'django/core/handlers/modpython.py') diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py index 07c98e3b59..db3c33147b 100644 --- a/django/core/handlers/modpython.py +++ b/django/core/handlers/modpython.py @@ -155,8 +155,11 @@ def populate_apache_request(http_response, mod_python_req): for c in http_response.cookies.values(): mod_python_req.headers_out.add('Set-Cookie', c.output(header='')) mod_python_req.status = http_response.status_code - for chunk in http_response.iterator: - mod_python_req.write(chunk) + try: + for chunk in http_response: + mod_python_req.write(chunk) + finally: + http_response.close() def handler(req): # mod_python hooks into this function. -- cgit v1.3