Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit86c29f5

Browse files
committed
test that http.client _tunnel closes the response on exceptions
1 parent5500734 commit86c29f5

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

‎Lib/test/test_httplib.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff 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+
deftest_tunnel_leak(self):
2391+
sock=None
2392+
2393+
def_create_connection(address,timeout=None,source_address=None):
2394+
nonlocalsock
2395+
sock=FakeSocket(
2396+
'HTTP/1.1 404 NOT FOUND\r\n\r\n',
2397+
host=address[0],
2398+
port=address[1],
2399+
)
2400+
returnsock
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+
exceptOSErrorase:
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-
withsupport.captured_stdout()asoutput:
2389-
self.conn.request('PUT','/','')
2390-
lines=output.getvalue().splitlines()
2391-
self.assertIn('header: {}'.format(expected_header),lines)
23922413

23932414

23942415
if__name__=='__main__':

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp