﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1445	Response middleware can leak db connection	Maniac <Maniac@…>	Adrian Holovaty	"Both modpython.py and wsgi.py do this:

{{{
    try:
        request = ModPythonRequest(req)
        response = self.get_response(req.uri, request)
    finally:
        db.db.close()

    # Apply response middleware
    for middleware_method in self._response_middleware:
        response = middleware_method(request, response)

}}}

... meaning that if any response middleware uses db connection it will not be closed. The most common middleware doing it is Session.

The right thing to do would be stick the middleware part up under try block. 

However even more right thing (I think) would be to refactor both request and response middleware application along with finally: part into BaseHandler._get_response to avoid maintaining identical code in modpython.py and wsgi.py."	defect	closed	contrib.admin		normal	fixed		Maniac@…	Unreviewed	0	0	0	0	0	0
