summaryrefslogtreecommitdiff
path: root/Lib/http/client.py
diff options
context:
space:
mode:
authorAlexey Namyotkin <62434915+nametkin@users.noreply.github.com>2023-05-05 21:52:24 +0300
committerGitHub <noreply@github.com>2023-05-05 18:52:24 +0000
commit1afe0e0320c6f19418d44d682ad95ba0c689c595 (patch)
treeca5a90d981c24ace231624c75195a5ae880530b6 /Lib/http/client.py
parentb9797417315cc2d1700cb2d427685016d3380711 (diff)
downloadcpython-git-1afe0e0320c6f19418d44d682ad95ba0c689c595.tar.gz
gh-69152: Add _proxy_response_headers attribute to HTTPConnection (#26152)
Add _proxy_response_headers attribute to HTTPConnection (#26152) --------- Co-authored-by: Senthil Kumaran <senthil@python.org>
Diffstat (limited to 'Lib/http/client.py')
-rw-r--r--Lib/http/client.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/Lib/http/client.py b/Lib/http/client.py
index 74f7bcb68f..50f2b46807 100644
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -858,6 +858,7 @@ class HTTPConnection:
self._tunnel_host = None
self._tunnel_port = None
self._tunnel_headers = {}
+ self._proxy_response_headers = None
(self.host, self.port) = self._get_hostport(host, port)
@@ -944,21 +945,16 @@ class HTTPConnection:
try:
(version, code, message) = response._read_status()
+ self._proxy_response_headers = parse_headers(response.fp)
+
+ if self.debuglevel > 0:
+ for hdr, val in self._proxy_response_headers.items():
+ print("header:", hdr + ":", val)
+
if code != http.HTTPStatus.OK:
self.close()
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()