Commit aac6c00c authored by Ralf Schmitt's avatar Ralf Schmitt

test__pywsgi.py: test that sockets are closed even if the wsgi app leaks the...

test__pywsgi.py: test that sockets are closed even if the wsgi app leaks the environ, the wsgi.input object or keeps a reference to a frame.

--HG--
extra : transplant_source : %8C%8E%D8%84%D2%0C%2A%A1%92%5E%25Q%29%AA%10%9E%AC7%09%A7
parent 602e714f
......@@ -858,6 +858,32 @@ Cookie: name2="value2"\n\n'''.replace('\n', '\r\n'))
read_http(fd)
class TestLeakInput(TestCase):
def application(self, environ, start_response):
pi = environ["PATH_INFO"]
self._leak_wsgi_input = environ["wsgi.input"]
self._leak_environ = environ
if pi == "/leak-frame":
environ["_leak"] = sys._getframe(0)
text = "foobar"
start_response('200 OK', [('Content-Length', str(len(text))), ('Content-Type', 'text/plain')])
return [text]
def test_connection_close_leak_simple(self):
fd = self.connect().makefile(bufsize=1)
fd.write("GET / HTTP/1.0\r\nConnection: close\r\n\r\n")
d = fd.read()
assert d.startswith("HTTP/1.0 200 OK"), "bad response"
def test_connection_close_leak_frame(self):
fd = self.connect().makefile(bufsize=1)
fd.write("GET /leak-frame HTTP/1.0\r\nConnection: close\r\n\r\n")
d = fd.read()
assert d.startswith("HTTP/1.0 200 OK"), "bad response"
del CommonTests
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment