File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -2390,6 +2390,29 @@ def test_tunnel_debuglog(self):
23902390 lines = output .getvalue ().splitlines ()
23912391 self .assertIn ('header: {}' .format (expected_header ), lines )
23922392
2393+ def test_tunnel_leak (self ):
2394+ sock = None
2395+
2396+ def _create_connection (address , timeout = None , source_address = None ):
2397+ nonlocal sock
2398+ sock = FakeSocket (
2399+ 'HTTP/1.1 404 NOT FOUND\r \n \r \n ' ,
2400+ host = address [0 ],
2401+ port = address [1 ],
2402+ )
2403+ return sock
2404+
2405+ self .conn ._create_connection = _create_connection
2406+ self .conn .set_tunnel ('destination.com' )
2407+ exc = None
2408+ try :
2409+ self .conn .request ('HEAD' , '/' , '' )
2410+ except OSError as e :
2411+ # keeping a reference to exc keeps response alive in the traceback
2412+ exc = e
2413+ self .assertIsNotNone (exc )
2414+ self .assertTrue (sock .file_closed )
2415+
23932416
23942417if __name__ == '__main__' :
23952418 unittest .main (verbosity = 2 )
You can’t perform that action at this time.
0 commit comments