File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -2383,12 +2383,33 @@ def test_tunnel_debuglog(self):
23832383
23842384 self .conn .set_debuglevel (1 )
23852385 self .conn ._create_connection = self ._create_connection (response_text )
2386+ self .conn .set_tunnel ("destination.com" )
2387+ self .conn .request ('HEAD' , '/' , '' )
2388+
2389+
2390+ def test_tunnel_leak (self ):
2391+ sock = None
2392+
2393+ def _create_connection (address , timeout = None , source_address = None ):
2394+ nonlocal sock
2395+ sock = FakeSocket (
2396+ 'HTTP/1.1 404 NOT FOUND\r \n \r \n ' ,
2397+ host = address [0 ],
2398+ port = address [1 ],
2399+ )
2400+ return sock
2401+
2402+ self .conn ._create_connection = _create_connection
23862403 self .conn .set_tunnel ('destination.com' )
2404+ exc = None
2405+ try :
2406+ self .conn .request ('HEAD' , '/' , '' )
2407+ except OSError as e :
2408+ # keeping a reference to exc keeps response alive in the traceback
2409+ exc = e
2410+ self .assertIsNotNone (exc )
2411+ self .assertTrue (sock .file_closed )
23872412
2388- with support .captured_stdout () as output :
2389- self .conn .request ('PUT' , '/' , '' )
2390- lines = output .getvalue ().splitlines ()
2391- self .assertIn ('header: {}' .format (expected_header ), lines )
23922413
23932414
23942415if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments