Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.4k
GH-103472: close response in HTTPConnection._tunnel#103473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
gpshead merged 8 commits intopython:mainfromgraingert:close-response-in-http-client-tunnelMay 2, 2023
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
8 commits Select commitHold shift + click to select a range
86952ce GH-103472: close response in HTTPConnection._tunnel
graingert6508762 📜🤖 Added by blurb_it.
blurb-it[bot]f88793c Update Misc/NEWS.d/next/Library/2023-04-12-13-04-16.gh-issue-103472.C…
graingert959db96 Merge branch 'main' into close-response-in-http-client-tunnel
graingert5500734 Merge branch 'main' into close-response-in-http-client-tunnel
graingert2aa460c test that HTTPConnection._tunnel closes the response on exceptions
graingertc2171c7 minor wording and ReST update to NEWS
gpsheadbd079b1 word wrap news.
gpsheadFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
test that HTTPConnection._tunnel closes the response on exceptions
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit2aa460c4986f4f9961206ef0b50ed85e48eb4298
There are no files selected for viewing
23 changes: 23 additions & 0 deletionsLib/test/test_httplib.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2390,6 +2390,29 @@ def test_tunnel_debuglog(self): | ||
| lines = output.getvalue().splitlines() | ||
| self.assertIn('header: {}'.format(expected_header), lines) | ||
| def test_tunnel_leak(self): | ||
| sock = None | ||
| def _create_connection(address, timeout=None, source_address=None): | ||
| nonlocal sock | ||
| sock = FakeSocket( | ||
| 'HTTP/1.1 404 NOT FOUND\r\n\r\n', | ||
| host=address[0], | ||
| port=address[1], | ||
| ) | ||
| return sock | ||
| self.conn._create_connection = _create_connection | ||
| self.conn.set_tunnel('destination.com') | ||
gpshead marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| exc = None | ||
| try: | ||
| self.conn.request('HEAD', '/', '') | ||
| except OSError as e: | ||
| # keeping a reference to exc keeps response alive in the traceback | ||
| exc = e | ||
| self.assertIsNotNone(exc) | ||
| self.assertTrue(sock.file_closed) | ||
| if __name__ == '__main__': | ||
| unittest.main(verbosity=2) | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.