Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.3k
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
Uh oh!
There was an error while loading.Please reload this page.
Changes from2 commits
86952ce
6508762
f88793c
959db96
5500734
2aa460c
c2171c7
bd079b1
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -941,23 +941,26 @@ def _tunnel(self): | ||
del headers | ||
response = self.response_class(self.sock, method=self._method) | ||
gpshead marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
try: | ||
(version, code, message) = response._read_status() | ||
if code != http.HTTPStatus.OK: | ||
self.close() | ||
gpshead marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
raise OSError(f"Tunnel connection failed: {code} {message.strip()}") | ||
while True: | ||
line = response.fp.readline(_MAXLINE + 1) | ||
if len(line) > _MAXLINE: | ||
raise LineTooLong("header line") | ||
if not line: | ||
# for sites which EOF without sending a trailer | ||
break | ||
if line in (b'\r\n', b'\n', b''): | ||
break | ||
if self.debuglevel > 0: | ||
print('header:', line.decode()) | ||
finally: | ||
response.close() | ||
gpshead marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
def connect(self): | ||
"""Connect to the host and port specified in __init__.""" | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
avoid a ResourceWarning in :class:`http.client.HTTPConnection` by closing tunnel CONNECT requests explicitly | ||
graingert marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. |