Close wsgi responses correctly - the close method, if present, will

be on the result of self.wsgi_application() and not on the list
of output we're building up.
This commit is contained in:
Ben Darnell 2010-06-18 15:59:19 -07:00
parent 39ac6d169a
commit df0d88eb8d
1 changed files with 5 additions and 4 deletions

View File

@ -219,11 +219,12 @@ class WSGIContainer(object):
data["status"] = status
data["headers"] = response_headers
return response.append
response.extend(self.wsgi_application(
WSGIContainer.environ(request), start_response))
app_response = self.wsgi_application(
WSGIContainer.environ(request), start_response)
response.extend(app_response)
body = "".join(response)
if hasattr(response, "close"):
response.close()
if hasattr(app_response, "close"):
app_response.close()
if not data: raise Exception("WSGI app did not call start_response")
status_code = int(data["status"].split()[0])